aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-04-15 02:41:04 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-04-15 02:41:04 +0000
commite4991ce586558b0ff3a06b7c0c4022d2083c4d01 (patch)
tree96e5d97482a50ae760cd9bdc8ea8401bd1bf6648 /externals/grill/flext/source
parentc58149336328a7c05d9c713368d30ea30ec0ac1b (diff)
""
svn path=/trunk/; revision=562
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flbase.h5
-rw-r--r--externals/grill/flext/source/flbind.cpp95
-rw-r--r--externals/grill/flext/source/flclass.h47
-rwxr-xr-xexternals/grill/flext/source/flcwmax-thr.h6
-rwxr-xr-xexternals/grill/flext/source/flcwmax-x-thr.h6
-rwxr-xr-xexternals/grill/flext/source/flcwmax-x.h6
-rw-r--r--externals/grill/flext/source/flcwmax.h6
-rw-r--r--externals/grill/flext/source/fldefs.h22
-rw-r--r--externals/grill/flext/source/flext.cpp2
-rw-r--r--externals/grill/flext/source/flinternal.h14
-rwxr-xr-xexternals/grill/flext/source/flitem.cpp43
-rwxr-xr-xexternals/grill/flext/source/fllib.cpp31
-rwxr-xr-xexternals/grill/flext/source/flmeth.cpp3
-rw-r--r--externals/grill/flext/source/flout.cpp6
-rwxr-xr-xexternals/grill/flext/source/flproxy.cpp3
-rw-r--r--externals/grill/flext/source/flsupport.h44
-rw-r--r--externals/grill/flext/source/flthr.cpp1
-rwxr-xr-xexternals/grill/flext/source/fltimer.cpp8
18 files changed, 289 insertions, 59 deletions
diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h
index 97e5f2b6..18ba2ca1 100644
--- a/externals/grill/flext/source/flbase.h
+++ b/externals/grill/flext/source/flbase.h
@@ -218,6 +218,10 @@ class FLEXT_SHARE flext_obj:
//! Flag for successful object construction
bool init_ok;
+ // --- proxy stuff for symbol-bound methods ----
+
+ static void SetupBindProxy();
+
public:
//! Creation callback
@@ -251,6 +255,7 @@ class FLEXT_SHARE flext_obj:
static flext_hdr *obj_new(const t_symbol *s,int argc,t_atom *argv);
static void obj_free(flext_hdr *o);
#endif
+
//! @} FLEXT_O_INTERNAL
//! @} FLEXT_OBJCLASS
diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp
new file mode 100644
index 00000000..3eee25ae
--- /dev/null
+++ b/externals/grill/flext/source/flbind.cpp
@@ -0,0 +1,95 @@
+/*
+
+flext - C++ layer for Max/MSP and pd (pure data) externals
+
+Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+/*! \file flbind.cpp
+ \brief Functionality for symbol-bound methods.
+*/
+
+#include "flext.h"
+#include "flinternal.h"
+
+
+t_class *flext_base::pxbnd_class = NULL;
+
+flext_base::binditem::binditem(int in,const t_symbol *sym,bool (*f)(flext_base *,t_symbol *s,int,t_atom *),pxbnd_object *p):
+ item(sym,0,NULL),fun(f),px(p)
+{}
+
+
+bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int,t_atom *))
+{
+ if(!bindhead)
+ bindhead = new itemarr;
+ else {
+ // Search for symbol
+ if(bindhead->Find(sym,0)) {
+ post("%s - Symbol already bound",thisName());
+ return false;
+ }
+ }
+
+ FLEXT_ASSERT(pxbnd_class);
+
+ pxbnd_object *px = (pxbnd_object *)object_new(pxbnd_class);
+
+ if(px) {
+ binditem *mi = new binditem(0,sym,fun,px);
+ bindhead->Add(mi);
+
+ px->init(this,mi);
+
+#if FLEXT_SYS == FLEXT_SYS_PD
+ pd_bind(&px->obj.ob_pd,const_cast<t_symbol *>(sym));
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ if(!sym->s_thing)
+ const_cast<t_symbol *>(sym)->s_thing = (t_object *)px;
+ else
+ error("%s - Symbol is already bound",thisName());
+#else
+# pragma warning("Not implemented")
+#endif
+ }
+ else
+ error("%s - Symbol proxy could not be created",thisName());
+
+ return true;
+}
+
+
+bool flext_base::UnbindMethod(const t_symbol *sym)
+{
+ item *it = bindhead?bindhead->Find(sym,0):NULL;
+ if(it) {
+ bool ok = bindhead->Remove(it);
+ if(ok) {
+ pxbnd_object *px = ((binditem *)it)->px;
+#if FLEXT_SYS == FLEXT_SYS_PD
+ pd_unbind(&px->obj.ob_pd,const_cast<t_symbol *>(sym));
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ if(sym->s_thing == (t_object *)px)
+ const_cast<t_symbol *>(sym)->s_thing = NULL;
+ else
+ error("%s - Binding not found",thisName());
+#else
+# pragma warning("Not implemented")
+#endif
+ object_free(&px->obj);
+ delete it;
+ }
+ return ok;
+ }
+ else
+ return true;
+}
+
+void flext_base::pxbnd_object::px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv)
+{
+ c->item->fun(c->base,(t_symbol *)s,argc,(t_atom *)argv);
+}
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 17385370..67926266 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -411,16 +411,8 @@ public:
bool Unbind(const char *c) { return Unbind(MakeSymbol(c)); }
#endif
-/*
- // Low level
-
- //! Bind object to a symbol
- static void DoUnbind(t_symbol *s,flext_obj *o);
- //! Unbind object from a symbol
- static void DoBind(const t_symbol *s,flext_obj *o);
- //! Get bound object of a symbol
- static t_class **GetBound(const t_symbol *s) { return (t_class **)s->s_thing; }
-*/
+ bool BindMethod(const t_symbol *s,bool (*m)(flext_base *,t_symbol *s,int,t_atom *));
+ bool UnbindMethod(const t_symbol *s);
//! @} FLEXT_C_BIND
@@ -555,6 +547,7 @@ protected:
~itemarr();
void Add(item *it);
+ bool Remove(item *it);
item *Find(const t_symbol *tag,int inlet = 0) const;
void Finalize();
@@ -606,6 +599,21 @@ protected:
methfun fun;
};
+private:
+ class pxbnd_object;
+public:
+
+ //! \brief This represents an item of the method list
+ class binditem:
+ public item {
+ public:
+ binditem(int inlet,const t_symbol *sym,bool (*f)(flext_base *,t_symbol *s,int,t_atom *),pxbnd_object *px);
+ ~binditem();
+
+ bool (*fun)(flext_base *,t_symbol *s,int,t_atom *);
+ pxbnd_object *px;
+ };
+
//! @} FLEXT_CLASS
itemarr *ThMeths() { return methhead; }
@@ -657,6 +665,7 @@ private:
static itemarr *GetClassArr(t_classid,int ix);
itemarr *methhead,*clmethhead;
+ itemarr *bindhead;
bool CallMeth(const methitem &m,int argc,const t_atom *argv);
bool FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv);
@@ -709,7 +718,6 @@ private:
static void px_method(px_object *c,const t_symbol *s,int argc,t_atom *argv);
};
- friend struct px_object;
#elif FLEXT_SYS == FLEXT_SYS_MAX
typedef object px_object;
static void cb_px_float(t_class *c,float f);
@@ -745,6 +753,23 @@ private:
static void jmax_proxy(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at);
#endif
+ // --------- symbol-bound proxy
+
+ static t_class *pxbnd_class;
+
+ class pxbnd_object // no virtual table!
+ {
+ public:
+ t_object obj; // MUST reside at memory offset 0
+ flext_base *base;
+ binditem *item;
+
+ void init(flext_base *b,binditem *it) { base = b; item = it; }
+ static void px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv);
+ };
+
+ // ---------
+
static void SetProxies(t_class *c);
bool InitInlets();
diff --git a/externals/grill/flext/source/flcwmax-thr.h b/externals/grill/flext/source/flcwmax-thr.h
index 9b3f3096..b3ef6edb 100755
--- a/externals/grill/flext/source/flcwmax-thr.h
+++ b/externals/grill/flext/source/flcwmax-thr.h
@@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-// This is the prefix file for CodeWarrior projects - threaded version
-
+/*! \file flcwmax-thr.h
+ \brief Prefix file for CodeWarrior projects - OS 9 threaded version.
+*/
+
#ifndef _FLEXT_CW_MAX_THR_H
#define _FLEXT_CW_MAX_THR_H
diff --git a/externals/grill/flext/source/flcwmax-x-thr.h b/externals/grill/flext/source/flcwmax-x-thr.h
index 13fcbfd3..0d2d8b3d 100755
--- a/externals/grill/flext/source/flcwmax-x-thr.h
+++ b/externals/grill/flext/source/flcwmax-x-thr.h
@@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-// This is the prefix file for CodeWarrior projects - threaded version
-
+/*! \file flcwmax-x-thr.h
+ \brief Prefix file for CodeWarrior projects - OS X threaded version.
+*/
+
#ifndef _FLEXT_CW_MAX_X_THR_H
#define _FLEXT_CW_MAX_X_THR_H
diff --git a/externals/grill/flext/source/flcwmax-x.h b/externals/grill/flext/source/flcwmax-x.h
index 6af4fb4d..bffff8d3 100755
--- a/externals/grill/flext/source/flcwmax-x.h
+++ b/externals/grill/flext/source/flcwmax-x.h
@@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-/* This is the prefix file for CodeWarrior projects - OS X version */
-
+/*! \file flcwmax-x.h
+ \brief Prefix file for CodeWarrior projects - OS X version.
+*/
+
#ifndef _FLEXT_CW_MAX_X_H
#define _FLEXT_CW_MAX_X_H
diff --git a/externals/grill/flext/source/flcwmax.h b/externals/grill/flext/source/flcwmax.h
index fea603ca..87653e3b 100644
--- a/externals/grill/flext/source/flcwmax.h
+++ b/externals/grill/flext/source/flcwmax.h
@@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-/* This is the prefix file for CodeWarrior projects */
-
+/*! \file flcwmax.h
+ \brief Prefix file for CodeWarrior projects - OS 9 version.
+*/
+
#ifndef _FLEXT_CW_MAX_H
#define _FLEXT_CW_MAX_H
diff --git a/externals/grill/flext/source/fldefs.h b/externals/grill/flext/source/fldefs.h
index da6d995c..98461d56 100644
--- a/externals/grill/flext/source/fldefs.h
+++ b/externals/grill/flext/source/fldefs.h
@@ -875,6 +875,28 @@ FLEXT_ADDMETHOD_3(IX,M_TAG,M_FUN,int,int,int)
//! @} FLEXT_D_ADDMETHOD
+
+/*! \defgroup FLEXT_D_BINDMETHOD Call flext methods manually
+ @{
+*/
+
+/*! \brief Bind a handler for a method with an anything argument to a symbol
+*/
+#define FLEXT_BINDMETHOD(SYM,M_FUN) \
+\
+BindMethod(SYM,FLEXT_CALL_PRE(M_FUN))
+
+/*! \brief Unbind any handler for a method from a symbol
+*/
+#define FLEXT_UNBINDMETHOD(SYM) \
+\
+UnbindMethod(SYM)
+
+
+//! @} FLEXT_D_BINDMETHOD
+
+
+
/*! \defgroup FLEXT_D_CALLMETHOD Call flext methods manually
@{
*/
diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp
index a5ee5a59..23d02893 100644
--- a/externals/grill/flext/source/flext.cpp
+++ b/externals/grill/flext/source/flext.cpp
@@ -38,6 +38,7 @@ flext_base::flext_base():
t_classid clid = thisClassId();
clmethhead = ClMeths(clid);
methhead = new itemarr;
+ bindhead = NULL;
if(procattr) {
// initialize when attribute processing is enabled
@@ -78,6 +79,7 @@ flext_base::~flext_base()
// delete message lists
if(methhead) delete methhead;
+ if(bindhead) delete bindhead;
if(attrhead) delete attrhead;
// destroy inlets and outlets and their proxy objects
diff --git a/externals/grill/flext/source/flinternal.h b/externals/grill/flext/source/flinternal.h
index af88cbca..c8cdcf2a 100644
--- a/externals/grill/flext/source/flinternal.h
+++ b/externals/grill/flext/source/flinternal.h
@@ -25,7 +25,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if FLEXT_SYS == FLEXT_SYS_PD
#define object_new(clss) pd_new(clss)
-#define object_free(obj) pd_free(&(obj).ob_pd)
+#define object_free(obj) pd_free(&(obj)->ob_pd)
@@ -68,16 +68,11 @@ typedef t_perfroutine t_dspmethod;
#elif FLEXT_SYS == FLEXT_SYS_MAX
-/*
-typedef void _inlet;
-typedef _inlet t_inlet;
-*/
-
typedef void t_outlet;
-//typedef _outlet t_outlet;
-#define object_new(clss) pd_new(clss)
-#define object_free(obj) freeobject((object *)obj)
+
+#define object_new(clss) newobject(clss)
+#define object_free(obj) freeobject((object *)(obj))
#define add_dsp(clss,meth) addmess((method)meth,"dsp",A_CANT,A_NOTHING)
#define add_bang(clss,meth) addbang((method)meth)
@@ -112,6 +107,7 @@ typedef t_perfroutine t_dspmethod;
#define CRITON() short state = lockout_set(1)
#define CRITOFF() lockout_set(state)
+
#elif FLEXT_SYS == FLEXT_SYS_JMAX
diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp
index 1e5a26a6..7af91fea 100755
--- a/externals/grill/flext/source/flitem.cpp
+++ b/externals/grill/flext/source/flitem.cpp
@@ -68,6 +68,49 @@ void flext_base::itemarr::Add(item *it)
}
}
+bool flext_base::itemarr::Remove(item *it)
+{
+ if(Ready()) {
+ // retrieve array index
+ int ix = Hash(it->tag,it->inlet,bits);
+
+ // remove from array slot
+ if(arr[ix]) {
+ item *a1 = NULL,*a = arr[ix];
+ while(a && a != it) a1 = a,a = a->nxt;
+ if(a) { // found (a == it)
+ if(a1) a1->nxt = it->nxt;
+ else arr[ix] = it->nxt;
+ it->nxt = NULL;
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
+ }
+ else {
+ // remove from list
+ if(!arr[0])
+ return false;
+ else {
+ item *a1 = NULL,*a = arr[0];
+ while(a && a != it) a1 = a,a = a->nxt;
+ if(a) { // found (a == it)
+ if(a1) a1->nxt = it->nxt;
+ else arr[0] = it->nxt;
+ if(!it->nxt) arr[1] = a1;
+ it->nxt = NULL;
+ --cnt;
+ return true;
+ }
+ else
+ return false;
+ }
+ }
+}
+
void flext_base::itemarr::Finalize()
{
if(!Ready())
diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp
index 281bad58..438f8bd0 100755
--- a/externals/grill/flext/source/fllib.cpp
+++ b/externals/grill/flext/source/fllib.cpp
@@ -8,9 +8,12 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
-// Code for handling of object creation functions
+/*! \file fllib.cpp
+ \brief Code for handling of object (and library) creation functions.
+*/
#include "flext.h"
+#include "flinternal.h"
#include <stdarg.h>
#include <string.h>
@@ -189,10 +192,33 @@ flext_obj::t_classid flext_obj::thisClassId() const { return libname::Find(thisN
t_class *flext_obj::getClass(t_classid id) { return reinterpret_cast<libobject *>(id)->clss; }
#endif
+/*! \brief Set up the proxy class for symbol-bound methods
+ \note This has to take place before the main class is set up because
+ \note Max does not know which class is the current one afterwards (when methods are added)
+*/
+void flext_obj::SetupBindProxy()
+{
+ // already initialized?
+ if(!flext_base::pxbnd_class) {
+#if FLEXT_SYS == FLEXT_SYS_PD
+ flext_base::pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(flext_base::pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL);
+ add_anything(flext_base::pxbnd_class,flext_base::pxbnd_object::px_method); // for symbol-bound methods
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ ::setup((t_messlist **)&flext_base::pxbnd_class,NULL,NULL,sizeof(flext_base::pxbnd_object),NULL,A_NULL);
+ add_anything(flext_base::pxbnd_class,flext_base::pxbnd_object::px_method); // for symbol-bound methods
+#else
+#pragma warning("Not implemented!")
+#endif
+ }
+}
+
+
void flext_obj::lib_init(const char *name,void setupfun(),bool attr)
{
flext::Setup();
+ SetupBindProxy();
+
#if FLEXT_SYS == FLEXT_SYS_MAX
lib_name = MakeSymbol(name);
::setup(
@@ -213,6 +239,9 @@ static void jmax_class_inst(t_class *cl)
void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),flext_obj *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...)
{
+ // set up bind proxy
+ SetupBindProxy();
+
// get first possible object name
const t_symbol *nsym = MakeSymbol(extract(names));
diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp
index acdd10b2..5e6a86b4 100755
--- a/externals/grill/flext/source/flmeth.cpp
+++ b/externals/grill/flext/source/flmeth.cpp
@@ -15,6 +15,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include <string.h>
#include <stdarg.h>
+#include "flinternal.h"
flext_base::methitem::methitem(int in,const t_symbol *tg,attritem *conn):
item(tg,in,conn),
@@ -34,6 +35,7 @@ void flext_base::methitem::SetArgs(methfun _fun,int _argc,metharg *_args)
argc = _argc,args = _args;
}
+
void flext_base::AddMethodDef(int inlet,const char *tag)
{
methhead->Add(new methitem(inlet,tag?MakeSymbol(tag):NULL));
@@ -85,4 +87,3 @@ void flext_base::AddMethod(itemarr *ma,int inlet,const char *tag,methfun fun,met
ma->Add(mi);
}
-
diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp
index 75da3023..c32f710f 100644
--- a/externals/grill/flext/source/flout.cpp
+++ b/externals/grill/flext/source/flout.cpp
@@ -64,7 +64,8 @@ bool flext_base::InitInlets()
incnt = insigs = 0;
- if(inlist) {
+ // digest inlist
+ {
xlet *xi;
incnt = 0;
for(xi = inlist; xi; xi = xi->nxt) ++incnt;
@@ -282,7 +283,8 @@ bool flext_base::InitOutlets()
attrtmp = (outlet *)newout_anything(thisHdr());
#endif
- if(outlist) {
+ // digest outlist
+ {
xlet *xi;
// count outlets
diff --git a/externals/grill/flext/source/flproxy.cpp b/externals/grill/flext/source/flproxy.cpp
index 75bbc897..2edcd4c9 100755
--- a/externals/grill/flext/source/flproxy.cpp
+++ b/externals/grill/flext/source/flproxy.cpp
@@ -105,6 +105,7 @@ void flext_base::SetProxies(t_class *c)
add_anything(c,cb_px_anything); // for leftmost inlet
px_class = class_new(gensym("flext_base proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL);
add_anything(px_class,px_object::px_method); // for other inlets
+
#elif FLEXT_SYS == FLEXT_SYS_MAX
add_bang(c,cb_px_bang);
add_method1(c,cb_px_int,"int",A_INT);
@@ -112,7 +113,7 @@ void flext_base::SetProxies(t_class *c)
add_methodG(c,cb_px_anything,"list");
add_anything(c,cb_px_anything);
#else
-#error
+#error Not implemented!
#endif
// setup non-leftmost ints and floats
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index a40ef6cf..867e2859 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -701,7 +701,7 @@ public:
//! Lock thread mutex
bool Lock() { return pthread_mutex_lock(&mutex) == 0; }
- /*! \brief Wait to lock thread mutex
+ /*! \brief Wait to lock thread mutex.
\todo Implement!
*/
bool WaitForLock(double tm) { return pthread_mutex_lock(&mutex) == 0; }
@@ -759,7 +759,7 @@ public:
return ret;
}
- /*! \brief Wait for condition (for a certain time)
+ /*! \brief Wait for condition (for a certain time).
\param ftime Wait time in seconds
\ret 0 = signalled, 1 = timed out
\remark Depending on the implementation ftime may not be fractional.
@@ -808,7 +808,7 @@ public:
//! Wait for condition
bool Wait() { return MPWaitForEvent(ev,NULL,kDurationForever) == noErr; }
- /*! \brief Wait for condition (for a certain time)
+ /*! \brief Wait for condition (for a certain time).
\param time Wait time in seconds
*/
bool TimedWait(double tm) { return MPWaitForEvent(ev,NULL,tm*kDurationMicrosecond*1.e6) == noErr; }
@@ -824,19 +824,19 @@ public:
#error "Not implemented"
#endif
- /*! \brief Add current thread to list of active threads
+ /*! \brief Add current thread to list of active threads.
\return true on success
\internal
*/
static bool PushThread();
- /*! \brief Remove current thread from list of active threads
+ /*! \brief Remove current thread from list of active threads.
\internal
*/
static void PopThread();
- /*! \brief Launch a thread
- \remark thr_params *p may be NULL if not needed
+ /*! \brief Launch a thread.
+ \remark thr_params *p may be NULL if not needed.
*/
static bool LaunchThread(void (*meth)(thr_params *p),thr_params *p = NULL);
@@ -855,28 +855,28 @@ public:
\remark Since this clock can be synchronized to an external clock (or e.g. the audio card)
\remark it may differ from the clock of the operating system
*/
- /*! \brief Get time since real-time system startup
+ /*! \brief Get time since real-time system startup.
\note This is not the time of the operating system but of the real-time system.
\note It depends on the time source the system is synchronized to.
*/
static double GetTime();
- /*! \brief Get time granularity of the GetTime function
+ /*! \brief Get time granularity of the GetTime function.
\note This can be zero if not determined.
*/
static double GetTimeGrain();
- /*! \brief Get operating system time since flext startup
+ /*! \brief Get operating system time since flext startup.
*/
static double GetOSTime();
- /*! \brief Sleep for an amount of time
- \remark The OS clock is used for that
- \note Clearly in a real-time system this should only be used in a detached thread
+ /*! \brief Sleep for an amount of time.
+ \remark The OS clock is used for that.
+ \note Clearly in a real-time system this should only be used in a detached thread.
*/
static void Sleep(double s);
- /*! \brief Class encapsulating a timer with callback functionality
+ /*! \brief Class encapsulating a timer with callback functionality.
This class can either be used with FLEXT_ADDTIMER or used as a base class with an overloaded virtual Work function.
*/
class FLEXT_SHARE Timer
@@ -885,23 +885,23 @@ public:
Timer(bool queued = false);
virtual ~Timer();
- //! Set timer callback function
+ //! Set timer callback function.
void SetCallback(void (*cb)(void *data)) { clss = NULL,cback = cb; }
- //! Set timer callback function (with class pointer)
+ //! Set timer callback function (with class pointer).
void SetCallback(flext_base &th,bool (*cb)(flext_base *th,void *data)) { clss = &th,cback = (void (*)(void *))cb; }
- //! Clear timer
+ //! Clear timer.
bool Reset();
- //! Trigger a one shot at an absolute time
+ //! Trigger a one shot at an absolute time.
bool At(double tm,void *data = NULL,bool dopast = true);
- //! Trigger a one shot interval
+ //! Trigger a one shot interval.
bool Delay(double tm,void *data = NULL);
- //! Trigger a periodic interval
+ //! Trigger a periodic interval.
bool Periodic(double tm,void *data = NULL);
- //! Trigger immediately
+ //! Trigger immediately.
bool Now(void *data = NULL) { return Delay(0,data); }
- //! Worker function, called on every timer event
+ //! Worker function, called on every timer event.
virtual void Work();
protected:
diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp
index df8fb1a1..7f9564d5 100644
--- a/externals/grill/flext/source/flthr.cpp
+++ b/externals/grill/flext/source/flthr.cpp
@@ -300,6 +300,7 @@ bool flext_base::StopThreads()
t = tn;
}
else t = t->nxt;
+ thrhead = NULL;
tlmutex.Unlock();
qmutex.Unlock();
diff --git a/externals/grill/flext/source/fltimer.cpp b/externals/grill/flext/source/fltimer.cpp
index 9b69de2b..6767c186 100755
--- a/externals/grill/flext/source/fltimer.cpp
+++ b/externals/grill/flext/source/fltimer.cpp
@@ -216,8 +216,8 @@ bool flext::Timer::Periodic(double tm,void *data)
return true;
}
-/*! \brief Callback function for system clock
- \todo Make periodic events scheduled as such
+/*! \brief Callback function for system clock.
+ \todo Make periodic events scheduled as such.
*/
void flext::Timer::callback(Timer *tmr)
{
@@ -244,12 +244,12 @@ void flext::Timer::callback(Timer *tmr)
}
#if FLEXT_SYS == FLEXT_SYS_MAX
-/*! \brief Callback function for low priority clock (for queued messages)
+/*! \brief Callback function for low priority clock (for queued messages).
*/
void flext::Timer::queuefun(Timer *tmr) { tmr->Work(); }
#endif
-/*! \brief Virtual worker function - by default it calls the user callback function
+/*! \brief Virtual worker function - by default it calls the user callback function.
\remark The respective callback parameter format is chosen depending on whether clss is defined or not.
*/
void flext::Timer::Work()