From 86806ae2e1bb2799ff57ad8279be922e51e082e7 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 7 Jun 2005 14:13:50 +0000 Subject: changed initialization functions accordingly small fix slimmed object data structures digest one-element list messages as single atoms made flext::Forward threadsafe small fixes simplified message analysis svn path=/trunk/; revision=3125 --- externals/grill/flext/source/flqueue.cpp | 57 ++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'externals/grill/flext/source/flqueue.cpp') diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 1cf2aab5..a9077230 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -49,20 +49,35 @@ public: return *this; } + inline qmsg &Set(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av) + { + th = NULL; + recv = r; + msg(s,ac,av); + return *this; + } + // \note PD sys lock must already be held by caller inline void Send() const { - if(out < 0) - // message to self - th->CbMethodHandler(-1-out,msg.Header(),msg.Count(),msg.Atoms()); + if(th) { + if(out < 0) + // message to self + th->CbMethodHandler(-1-out,msg.Header(),msg.Count(),msg.Atoms()); + else + // message to outlet + th->ToSysAnything(out,msg.Header(),msg.Count(),msg.Atoms()); + } else - // message to outlet - th->ToSysAnything(out,msg.Header(),msg.Count(),msg.Atoms()); + flext::Forward(recv,msg,true); } private: flext_base *th; - int out; + union { + int out; + const t_symbol *recv; + }; AtomAnything msg; }; @@ -86,6 +101,15 @@ public: Trigger(); } + inline void Push(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av) + { + qmsg *m = QueueFifo::New(); + FLEXT_ASSERT(m); + m->Set(r,s,ac,av); + Put(m); + Trigger(); + } + inline void Push(flext_base *th,int o) // bang { Push(th,o,sym_bang,0,NULL); @@ -336,3 +360,24 @@ void flext_base::ToQueueAnything(int o,const t_symbol *s,int argc,const t_atom * { queue.Push(const_cast(this),o,s,argc,argv); } + + +bool flext::Forward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv,bool direct) +{ + if(direct || IsSystemThread()) { + void *cl = recv->s_thing; + if(!cl) return false; + +#if FLEXT_SYS == FLEXT_SYS_PD + pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv); +#elif FLEXT_SYS == FLEXT_SYS_MAX + typedmess(recv->s_thing,(t_symbol *)s,argc,(t_atom *)argv); +#else +#error Not implemented +#endif + } + else + // send over queue + queue.Push(recv,s,argc,argv); + return true; +} -- cgit v1.2.1