aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flclass.h
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext/source/flclass.h')
-rw-r--r--externals/grill/flext/source/flclass.h99
1 files changed, 12 insertions, 87 deletions
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index dd51d85a..ab90667a 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -40,7 +40,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-class flext_base:
+class FLEXT_EXT flext_base:
public flext_obj
{
FLEXT_HEADER_S(flext_base,flext_obj,Setup)
@@ -392,6 +392,12 @@ public:
@{
*/
+ //! Start a thread for this object
+ bool StartThread(void (*meth)(thr_params *p),thr_params *p,const char *) { p->cl = this; return flext::LaunchThread(meth,p); }
+
+ //! Terminate all threads of this object
+ bool StopThreads();
+
//! Check if current thread should terminate
bool ShouldExit() const;
@@ -403,75 +409,6 @@ public:
protected:
-// --- thread stuff -----------------------------------------------
-
-#ifdef FLEXT_THREADS
-
- /*! \brief Thread parameters
- \internal
- */
- class thr_params:
- public flext
- {
- public:
- thr_params(flext_base *c,int n = 1);
- ~thr_params();
-
- void set_any(const t_symbol *s,int argc,const t_atom *argv);
- void set_list(int argc,const t_atom *argv);
-
- flext_base *cl;
- union _data {
- bool _bool;
- float _float;
- int _int;
- t_symptr _t_symptr;
- struct { AtomAnything *args; } _any;
- struct { AtomList *args; } _list;
- struct { void *data; } _ext;
- } *var;
- };
-
- /*! \brief This represents an entry to the list of active method threads
- \internal
- */
- class thr_entry
- {
- public:
- thr_entry(flext_base *t,void *(*m)(thr_params *),thr_params *p,pthread_t id = pthread_self());
-
- //! \brief Check if this class represents the current thread
- bool Is(pthread_t id = pthread_self()) const { return pthread_equal(thrid,id) != 0; }
-
- flext_base *th;
- void *(*meth)(thr_params *);
- thr_params *params;
- pthread_t thrid;
- bool active,shouldexit;
- thr_entry *nxt;
- };
-
- /*! \brief Add current thread to list of active threads
- \return true on success
- \internal
- */
- bool PushThread();
-
- /*! \brief Remove current thread from list of active threads
- \internal
- */
- void PopThread();
-
-public:
- /*! \brief Start a method thread
- \internal
- */
- bool StartThread(void *(*meth)(thr_params *p),thr_params *p,char *methname);
-
-#endif
-
-protected:
-
flext_base();
virtual ~flext_base();
@@ -630,30 +567,18 @@ private:
static bool cb_GetAttrib(flext_base *c,const t_symbol *s,int argc,const t_atom *argv) { return c->GetAttrib(s,argc,argv); }
static bool cb_SetAttrib(flext_base *c,const t_symbol *s,int argc,const t_atom *argv) { return c->SetAttrib(s,argc,argv); }
-#ifdef FLEXT_THREADS
- ThrMutex qmutex;
-
- static thr_entry *thrhead,*thrtail;
- static ThrMutex tlmutex;
-
- static pthread_t thrhelpid;
- static bool StartHelper();
- static bool StopHelper();
- static void ThrHelper(void *);
- void TermThreads();
-#endif
+ // queue stuff
class qmsg;
qmsg *qhead,*qtail;
t_qelem *qclk;
-#if FLEXT_SYS == FLEXT_SYS_MAX
- t_clock *yclk;
- static void YTick(flext_base *th);
-#endif
-
static void QTick(flext_base *th);
void Queue(qmsg *m);
+#ifdef FLEXT_THREADS
+ ThrMutex qmutex;
+#endif
+
#if FLEXT_SYS == FLEXT_SYS_PD
// proxy object (for additional inlets) stuff