Commit 3dfbc7fe authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@261 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent e16f2713
......@@ -442,6 +442,7 @@ static void *thr_ ## M_FUN(thr_params *p) { \
th->M_FUN(data); \
th->PopThread(); \
} \
delete data; \
return NULL; \
}
......
......@@ -51,13 +51,17 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me
}
}
bool flext_base::PushThread()
{
tlmutex.Lock();
thr_entry *nt = new thr_entry;
if(thrtail) thrtail->nxt = nt;
else thrhead = nt;
thrtail = nt;
tlmutex.Unlock();
#ifdef MAXMSP
......@@ -69,6 +73,7 @@ bool flext_base::PushThread()
void flext_base::PopThread()
{
tlmutex.Lock();
thr_entry *prv = NULL,*ti;
for(ti = thrhead; ti; prv = ti,ti = ti->nxt)
if(ti->Is()) break;
......@@ -77,13 +82,15 @@ void flext_base::PopThread()
if(prv)
prv->nxt = ti->nxt;
else
thrhead = thrtail = ti->nxt;
thrhead = ti->nxt;
if(!ti->nxt) thrtail = ti;
ti->nxt = NULL;
delete ti;
}
else {
#ifdef _DEBUG
post("%s - Am i too slow? - Thread not found!",thisName());
post("%s - INTERNAL ERROR: Thread not found!",thisName());
#endif
}
......@@ -302,7 +309,7 @@ void flext_base::QueueAnything(outlet *o,const t_symbol *s,int argc,t_atom *argv
flext_base::thr_params::thr_params(flext_base *c,int n): cl(c),var(new _data[n]) {}
flext_base::thr_params::~thr_params() { delete[] var; }
flext_base::thr_params::~thr_params() { if(var) delete[] var; }
void flext_base::thr_params::set_any(const t_symbol *s,int argc,t_atom *argv) { var[0]._any.args = new AtomAnything(s,argc,argv); }
void flext_base::thr_params::set_list(int argc,t_atom *argv) { var[0]._list.args = new AtomList(argc,argv); }
......
......@@ -47,7 +47,7 @@ class flext_base::thr_entry
public:
thr_entry(pthread_t id = pthread_self()): thrid(id),nxt(NULL) {}
bool Is(pthread_t id = pthread_self()) const { return pthread_equal(thrid,id) != 0; }
bool Is(pthread_t id = pthread_self()) const { return pthread_equal(thrid,id) == 0; }
pthread_t thrid;
thr_entry *nxt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment