aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flqueue.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-02-27 04:56:10 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-02-27 04:56:10 +0000
commit3e90874e5d63137c195c3b3c1ce90b542deb8a51 (patch)
tree95f9b19ec8a3f579f976c3d80e4eae639867ea97 /externals/grill/flext/source/flqueue.cpp
parent7d9437c8a5fed2d03c22454f643b4bf5598f2d9e (diff)
small name change and reuse of Fifo cells
fixed eol-style new lock-free lifo and fifo fixes for linux eliminated ChannelsIn/ChannelsOut updated docs build system: added profiler mode, more fixes fix for linux autodetection of build platform fix for flext_dsp @ Max svn path=/trunk/; revision=2584
Diffstat (limited to 'externals/grill/flext/source/flqueue.cpp')
-rwxr-xr-xexternals/grill/flext/source/flqueue.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp
index 62a8b35a..75f7842e 100755
--- a/externals/grill/flext/source/flqueue.cpp
+++ b/externals/grill/flext/source/flqueue.cpp
@@ -29,7 +29,7 @@ flext::thrid_t flext::thrmsgid = 0;
class qmsg:
public flext,
- public Cell
+ public Fifo::Cell
{
public:
qmsg(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
@@ -37,6 +37,13 @@ public:
, th(t),out(o)
{}
+ void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
+ {
+ th = t;
+ out = o;
+ msg(s,ac,av);
+ }
+
// \note PD sys lock must already be held by caller
void Send() const
{
@@ -59,28 +66,26 @@ private:
*/
class Queue:
public flext,
- public Fifo
+ public TypedFifo<qmsg>
{
public:
inline bool Empty() const { return Size() == 0; }
- inline void Push(qmsg *q) { Fifo::Put(q); }
-
- inline qmsg *Pop() { return static_cast<qmsg *>(Fifo::Get()); }
+ void New(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av);
- void Push(flext_base *th,int o) // bang
+ inline void Push(flext_base *th,int o) // bang
{
- Put(new qmsg(th,o,sym_bang,0,NULL));
+ New(th,o,sym_bang,0,NULL);
}
- void Push(flext_base *th,int o,float dt)
+ inline void Push(flext_base *th,int o,float dt)
{
t_atom at;
SetFloat(at,dt);
- Put(new qmsg(th,o,sym_float,1,&at));
+ New(th,o,sym_float,1,&at);
}
- void Push(flext_base *th,int o,int dt)
+ inline void Push(flext_base *th,int o,int dt)
{
t_atom at;
SetInt(at,dt);
@@ -92,14 +97,14 @@ public:
#else
#error Not implemented!
#endif
- Put(new qmsg(th,o,sym,1,&at));
+ New(th,o,sym,1,&at);
}
- void Push(flext_base *th,int o,const t_symbol *dt)
+ inline void Push(flext_base *th,int o,const t_symbol *dt)
{
t_atom at;
SetSymbol(at,dt);
- Put(new qmsg(th,o,sym_symbol,1,&at));
+ New(th,o,sym_symbol,1,&at);
}
void Push(flext_base *th,int o,const t_atom &a)
@@ -121,21 +126,31 @@ public:
error("atom type not supported");
return;
}
- Put(new qmsg(th,o,sym,1,&a));
+ New(th,o,sym,1,&a);
}
- void Push(flext_base *th,int o,int argc,const t_atom *argv)
+ inline void Push(flext_base *th,int o,int argc,const t_atom *argv)
{
- Put(new qmsg(th,o,sym_list,argc,argv));
+ New(th,o,sym_list,argc,argv);
}
- void Push(flext_base *th,int o,const t_symbol *sym,int argc,const t_atom *argv)
+ inline void Push(flext_base *th,int o,const t_symbol *sym,int argc,const t_atom *argv)
{
- Put(new qmsg(th,o,sym,argc,argv));
+ New(th,o,sym,argc,argv);
}
};
-static Queue queue;
+static Queue queue,requeue;
+
+void Queue::New(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
+{
+ qmsg *m = requeue.Get();
+ if(m)
+ m->Set(t,o,s,ac,av);
+ else
+ m = new qmsg(t,o,s,ac,av);
+ Put(m);
+}
#if FLEXT_QMODE == 2
@@ -163,9 +178,9 @@ static void QWork(bool syslock)
#endif
qmsg *q;
- while((q = queue.Pop()) != NULL) {
+ while((q = queue.Get()) != NULL) {
q->Send();
- delete q;
+ requeue.Put(q);
}
#if FLEXT_QMODE == 2