aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext')
-rw-r--r--externals/grill/flext/changes.txt2
-rw-r--r--externals/grill/flext/source/flclass.h4
-rw-r--r--externals/grill/flext/source/flout.cpp27
-rwxr-xr-xexternals/grill/flext/source/flqueue.cpp6
-rw-r--r--externals/grill/flext/source/flsupport.h2
5 files changed, 25 insertions, 16 deletions
diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt
index b1999338..ed9aaa44 100644
--- a/externals/grill/flext/changes.txt
+++ b/externals/grill/flext/changes.txt
@@ -25,7 +25,7 @@ Version history:
- flext::StopThread function to terminate running threads (started with LaunchThread)
- added flext::post() and flext::error() console printing (thread-safe)
- added flext::CmpAtom and AtomList::operator < methods ... useful for using lists as keys for STL
-- make use of new PD thread locking (PD functions sys_lock() and sys_unlock())
+- make use of new PD thread locking (PD functions sys_lock() and sys_unlock()), queue messages only if necessary
- better FLEXT_OSAPI resolution
- ListAttributes (or the getattributes message) now lists attributes in the order they were created (first class, then object scope)
- enforcing usage of STL
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 17842bd2..721c3f5f 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -835,6 +835,10 @@ private:
//! Start message queue
static void StartQueue();
+#ifdef FLEXT_QTHR
+ //! Queue worker function
+ static void QWorker(thr_params *);
+#endif
//! Flush messages in the queue
static void QFlush(flext_base *th = NULL);
diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp
index a2f69978..85a9b934 100644
--- a/externals/grill/flext/source/flout.cpp
+++ b/externals/grill/flext/source/flout.cpp
@@ -38,22 +38,23 @@ void flext_base::ToSysAnything(int n,const t_symbol *s,int argc,const t_atom *ar
#error Not implemented
#endif
-#ifndef FLEXT_THREADS
-void flext_base::ToOutBang(int n) const { ToSysBang(n); }
-void flext_base::ToOutFloat(int n,float f) const { ToSysFloat(n,f); }
-void flext_base::ToOutInt(int n,int f) const { ToSysInt(n,f); }
-void flext_base::ToOutSymbol(int n,const t_symbol *s) const { ToSysSymbol(n,s); }
-void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { ToSysList(n,argc,argv); }
-void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { ToSysAnything(n,s,argc,argv); }
+#if defined(FLEXT_THREADS)
+ #if defined(FLEXT_QTHR)
+ #define CHKTHR() (IsSystemThread() || IsThread(flext::thrmsgid))
+ #else
+ #define CHKTHR() IsSystemThread()
+ #endif
#else
-void flext_base::ToOutBang(int n) const { if(IsSystemThread()) ToSysBang(n); else ToQueueBang(n); }
-void flext_base::ToOutFloat(int n,float f) const { if(IsSystemThread()) ToSysFloat(n,f); else ToQueueFloat(n,f); }
-void flext_base::ToOutInt(int n,int f) const { if(IsSystemThread()) ToSysInt(n,f); else ToQueueInt(n,f); }
-void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(IsSystemThread()) ToSysSymbol(n,s); else ToQueueSymbol(n,s); }
-void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(IsSystemThread()) ToSysList(n,argc,argv); else ToQueueList(n,argc,argv); }
-void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(IsSystemThread()) ToSysAnything(n,s,argc,argv); else ToQueueAnything(n,s,argc,argv); }
+ #define CHKTHR() true
#endif
+void flext_base::ToOutBang(int n) const { if(CHKTHR()) ToSysBang(n); else ToQueueBang(n); }
+void flext_base::ToOutFloat(int n,float f) const { if(CHKTHR()) ToSysFloat(n,f); else ToQueueFloat(n,f); }
+void flext_base::ToOutInt(int n,int f) const { if(CHKTHR()) ToSysInt(n,f); else ToQueueInt(n,f); }
+void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(CHKTHR()) ToSysSymbol(n,s); else ToQueueSymbol(n,s); }
+void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysList(n,argc,argv); else ToQueueList(n,argc,argv); }
+void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysAnything(n,s,argc,argv); else ToQueueAnything(n,s,argc,argv); }
+
bool flext_base::InitInlets()
{
diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp
index a75b4a89..ee1da752 100755
--- a/externals/grill/flext/source/flqueue.cpp
+++ b/externals/grill/flext/source/flqueue.cpp
@@ -19,6 +19,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include "flinternal.h"
+//! Thread id of message queue thread
+flext::thrid_t flext::thrmsgid = 0;
+
class qmsg
{
public:
@@ -237,8 +240,9 @@ static void Queue(qmsg *m)
}
#ifdef FLEXT_QTHR
-void QWorker(flext::thr_params *)
+void flext_base::QWorker(thr_params *)
{
+ thrmsgid = GetThreadId();
for(;;) {
qthrcond.Wait();
QWork(true,true);
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index f336d0de..5ec2b64a 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -720,7 +720,7 @@ public:
protected:
- static thrid_t thrhelpid;
+ static thrid_t thrhelpid,thrmsgid;
static bool StartHelper();
static bool StopHelper();
static void ThrHelper(void *);