Commit cdad0754 authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@174 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 903497cb
......@@ -37,6 +37,10 @@ flext_obj :: flext_obj()
m_canvas = (t_patcher *)gensym("#P")->s_thing;
x_obj->curinlet = 0;
#endif
#ifdef FLEXT_THREADS
thrid = pthread_self();
#endif
}
/////////////////////////////////////////////////////////
......
......@@ -21,6 +21,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <flstdc.h>
#ifdef FLEXT_THREADS
#include <pthread.h>
#endif
class flext_obj;
......@@ -121,7 +124,11 @@ class FLEXT_EXT flext_obj
#elif defined(MAXMSP)
t_class *thisClass() { return (t_class *)(((t_tinyobject *)x_obj)->t_messlist-1); }
#endif
#ifdef FLEXT_THREADS
bool IsSystemThread() const { pthread_t cur = pthread_self(); return pthread_equal(cur,thrid) != 0; }
#endif
protected:
//! The object header
......@@ -132,6 +139,11 @@ class FLEXT_EXT flext_obj
//! The canvas (patcher) that the object is in
t_canvas *m_canvas;
#ifdef FLEXT_THREADS
//! The thread that created the object (the system thread)
pthread_t thrid;
#endif
public:
//! Creation callback
......
......@@ -237,7 +237,7 @@ public:
//! output anything (index n starts with 0)
void ToOutAnything(int n,const t_symbol *s,int argc,t_atom *argv) { outlet *o = GetOut(n); if(o) ToOutAnything(o,const_cast<t_symbol *>(s),argc,argv); }
// --- message handling -------------------------------------------
enum metharg {
......@@ -385,6 +385,15 @@ protected:
void DescOutlet(int ix,const char *desc) { DescXlet(ix,desc,outlist); }
#ifdef FLEXT_THREADS
void QueueBang(outlet *o);
void QueueFloat(outlet *o,float f);
void QueueInt(outlet *o,int f);
void QueueSymbol(outlet *o,const t_symbol *s);
void QueueList(outlet *o,int argc,t_atom *argv);
void QueueAnything(outlet *o,const t_symbol *s,int argc,t_atom *argv);
#endif
// method handling
class methitem {
......
......@@ -215,14 +215,21 @@ void flext_base::AddOutlets(unsigned long code)
}
#ifndef FLEXT_THREADS
void flext_base::ToOutBang(outlet *o) { outlet_bang((t_outlet *)o); }
void flext_base::ToOutFloat(outlet *o,float f) { outlet_float((t_outlet *)o,f); }
void flext_base::ToOutInt(outlet *o,int f) { outlet_flint((t_outlet *)o,f); }
void flext_base::ToOutSymbol(outlet *o,const t_symbol *s) { outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(s)); }
void flext_base::ToOutList(outlet *o,int argc,t_atom *argv) { outlet_list((t_outlet *)o,gensym("list"),argc,argv); }
void flext_base::ToOutAnything(outlet *o,const t_symbol *s,int argc,t_atom *argv) { outlet_anything((t_outlet *)o,const_cast<t_symbol *>(s),argc,argv); }
#else
void flext_base::ToOutBang(outlet *o) { if(IsSystemThread()) outlet_bang((t_outlet *)o); else QueueBang(o); }
void flext_base::ToOutFloat(outlet *o,float f) { if(IsSystemThread()) outlet_float((t_outlet *)o,f); else QueueFloat(o,f); }
void flext_base::ToOutInt(outlet *o,int f) { if(IsSystemThread()) outlet_flint((t_outlet *)o,f); else QueueInt(o,f); }
void flext_base::ToOutSymbol(outlet *o,const t_symbol *s) { if(IsSystemThread()) outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(s)); else QueueSymbol(o,s); }
void flext_base::ToOutList(outlet *o,int argc,t_atom *argv) { if(IsSystemThread()) outlet_list((t_outlet *)o,gensym("list"),argc,argv); else QueueList(o,argc,argv); }
void flext_base::ToOutAnything(outlet *o,const t_symbol *s,int argc,t_atom *argv) { if(IsSystemThread()) outlet_anything((t_outlet *)o,const_cast<t_symbol *>(s),argc,argv); else QueueAnything(o,s,argc,argv); }
#endif
bool flext_base::SetupInOut()
{
......
......@@ -30,7 +30,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// include pthreads if threading is enabled
#ifdef FLEXT_THREADS
#include <pthread.h>
#include <flthr.h>
#endif
......
......@@ -18,6 +18,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// threading must be turned on
#ifdef FLEXT_THREADS
#include <pthread.h>
class thr_params {
public:
thr_params(flext_base *c): cl(c) {}
......
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