Commit 43fee227 authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@201 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 7ced185f
......@@ -73,8 +73,9 @@ Version history:
0.3.0:
- added threaded methods along with a message queue for ToOut* functions (very unstable for MaxMSP!)
to use threads compile flext with FLEXT_THREADS definition
- check/update function for buffer change (resize etc.)
- description text for inlets/outlets (e.g. for MaxMSPs assist function)
- description text for inlets/outlets (e.g. for MaxMSPs assist function) - not fully implemented
- added buffer resize functions flext_base::buffer::Frames(int,bool)
- added some utility functions: Sleep, CopyAtom, CopyList
- added List manipulation classes: AtomList, AtomAnything
......@@ -155,15 +156,16 @@ Version history:
----------------------------------------------------------------------------
Notes:
- no support for default object arguments (A_DEFFLOAT, A_DEFSYMBOL) -> use GIMME instead
- no support for default object arguments (A_DEFFLOAT, A_DEFSYMBOL) -> use variable argument lists instead
Platform specific:
- PD does not allow signal and message to go into the same inlet
- PD doesn't allow a signal object to receive float messages in the leftmost inlet... these are converted to a static signal
- PD needs all t_symbol or pointer args before float args -> you have to use variable argument lists in that case
Restrictions in compatibility mode:
- Max allows only 9 float/int inlets
- Max allows only 3 typed creation arguments -> use GIMME for more
- Max allows only 3 type-checked creation arguments -> use variable argument lists for more
Porting to new platforms:
- enums must be int-sized
......@@ -181,6 +183,8 @@ general:
- where to put flext source/lib in linux: /usr/local/lib,/usr/local/include ?
- clean up headers (eliminate flstdc.h?)
- check that SetupInOut is only called once
- feed assist function with in/outlet description
- MaxMSP: how to call separate help files for objects in a library?
bugs:
- PD: problems with timed buffer redrawing (takes a lot of cpu time)
......@@ -190,19 +194,19 @@ bugs:
tests:
- PD: figure out what "pointer" messages do and where they occur
- some more mutexes needed for thread safety?
- test alias names with MaxMSP
- buffer resize: flext_base::buffer::Frames(): should we use buffer or system sample rate?
- PD: test argument order (t_symbol, pointers before floats)
features:
- abstraction for parsing argument lists
- abstraction for clock functions
- sending messages to own inlet (passing computation to other patch objects - message queue?)
- manage running threads individually (stop, isrunning? etc.)
premature thoughts:
- explore jMax interface style
- interface for scripting language modules? (python?)
- GUI objects
......@@ -175,9 +175,9 @@ REAL_LIB_3(NAME,NEW_CLASS, 1, TYPE1, TYPE2, TYPE3)
// deprecated
#define FLEXT_NEW_G FLEXT_NEW_V
#define FLEXT_NEW_DSP_G FLEXT_NEW_DSP_V
#define FLEXT_NEW_TILDE_G FLEXT_NEW_DSP_V
#define FLEXT_LIB_G FLEXT_LIB_V
#define FLEXT_LIB_DSP_G FLEXT_LIB_DSP_V
#define FLEXT_LIB_TILDE_G FLEXT_LIB_DSP_V
// MaxMSP doesn't seem to be able to handle more than 3 creation arguments! -> USE GIMME
......@@ -323,7 +323,7 @@ static void cb_ ## M_FUN(flext_base *c,int &arg1) { \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
bool ok = th->PushThread(); \
bool b = p->var[0]; \
bool b = p->var[0]._bool; \
delete p; \
if(ok) { \
th->M_FUN(b); \
......
......@@ -12,7 +12,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <flinternal.h>
#include <string.h>
#include <stdarg.h>
#include <typeinfo.h>
// === proxy class for flext_base ============================
......
......@@ -40,6 +40,11 @@ void flext_base::AddXlet(xlet::type tp,int mult,const char *desc,xlet *&root)
}
}
void flext_base::DescXlet(int ix,const char *desc,xlet *&root)
{
post("flext - sorry, not implemented");
}
unsigned long flext_base::XletCode(xlet::type tp,...)
{
unsigned long code = 0;
......
/*
flext tutorial - simple 3
Copyright (c) 2002 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.
-------------------------------------------------------------------------
*/
// include flext header
#include <flext.h>
// check for appropriate flext version
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 300)
#error You need at least flext version 0.3.0
#endif
class simple3:
public flext_base
{
FLEXT_HEADER(simple3,flext_base)
public:
// constructor with variable argument list
simple3(int argc,t_atom *argv);
protected:
void m_tag();
void m_sym(t_symbol *s);
private:
FLEXT_CALLBACK(m_tag); // callback for method "m_tag" (no arguments)
FLEXT_CALLBACK_S(m_sym); // callback for method "m_sym" (with one symbol argument)
};
// instantiate the class (constructor has a variable argument list)
FLEXT_NEW_V("simple3",simple3)
simple3::simple3(int argc,t_atom *argv)
{
post("%i creation arguments",argc);
// define inlets
AddInAnything(); // first inlet of type anything (index 0)
// set up inlets and outlets
SetupInOut();
// register methods
FLEXT_ADDMETHOD_(0,"born",m_tag); // register method for tag "born"
FLEXT_ADDMETHOD_(0,"to",m_tag); // register method for tag "to"
FLEXT_ADDMETHOD_(0,"hula",m_tag); // register method for tag "hula"
FLEXT_ADDMETHOD(0,m_sym); // register method for all other symbol
}
void simple3::m_tag()
{
post("tag used");
}
void simple3::m_sym(t_symbol *s)
{
post("symbol: %s",GetString(s));
}
......@@ -10,119 +10,121 @@ WARRANTIES, see the file, "license.txt," in this distribution.
This shows an example of multiple threads and syncing with a thread conditional
*/
// define FLEXT_THREADS for thread usage. Flext must also have been compiled with that defined!
#define FLEXT_THREADS
#include <flext.h>
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 300)
#error You need at least flext version 0.3.0
#endif
class thread2:
public flext_base
{
FLEXT_HEADER(thread2,flext_base)
public:
thread2(int del,t_symptr txt);
thread2(int del);
protected:
void m_start(int st);
void m_stop();
void m_blip();
void m_text();
void m_textout();
private:
FLEXT_THREAD_I(m_start); // define threaded callback for method m_start
FLEXT_CALLBACK(m_stop); // normal callback for m_stop
FLEXT_THREAD(m_blip); // define threaded callback for method m_blip
FLEXT_CALLBACK(m_text); // turn on console output
FLEXT_THREAD(m_textout); // text output
float delay;
volatile bool stopit,running,blipping;
int count;
t_symbol *bliptxt;
volatile int count;
ThrCond cond;
// caution: CodeWarrior seems to ignore volatile modifier!!
volatile bool stopit,running,blipping; // flags for running and stopping
volatile int flag;
// thread conditional for stop signal
ThrCond cond;
};
FLEXT_NEW_2("thread2",thread2,int,t_symptr)
FLEXT_NEW_1("thread2",thread2,int)
thread2::thread2(int del,t_symptr txt):
thread2::thread2(int del):
delay(del/1000.f),
bliptxt(txt),
stopit(false),
running(false),blipping(false)
{
flag = 0;
AddInAnything();
AddOutInt();
AddOutInt(2);
SetupInOut(); // set up inlets and outlets
FLEXT_ADDMETHOD(0,m_start);
FLEXT_ADDMETHOD_(0,"stop",m_stop);
FLEXT_ADDMETHOD(0,m_start); // register start for integer numbers (floats in PD)
FLEXT_ADDMETHOD_(0,"text",m_text); // register m_text method for "text" tag
FLEXT_ADDMETHOD_(0,"stop",m_stop); // register m_text method for "stop" tag
}
void thread2::m_start(int st)
{
++flag;
post("start 1 - thr = %x",this);
// if already running, just set back the counter
if(running) { count = st; return; }
running = true;
blipping = false;
// FLEXT_CALLMETHOD(m_blip);
post("start 2");
// loop until either the system exit flag or the "stopit" flag is set
for(count = st; !ShouldExit() && !stopit; ++count)
{
Sleep(delay);
ToOutInt(0,count);
ToOutInt(0,count); // output loop count
}
post("start 3");
cond.Lock();
running = false;
cond.Signal();
cond.Unlock();
post("start 4 - r = %i, b = %i",running?1:0,blipping?1:0);
cond.Lock(); // lock conditional
running = false; // change state flag
cond.Signal(); // signal changed flag to watiting "stop" method
cond.Unlock(); // unlock conditional
}
void thread2::m_stop()
{
post("stop 1 - thr = %x",this);
post("flag = %i",flag);
cond.Lock(); // lock conditional
stopit = true; // set termination flag
// cond.Lock();
stopit = true;
while(*(&running) || *(&blipping)) {
// cond.Wait();
Sleep(1.f);
post("stop 2 - r = %i, b = %i",*(&running)?1:0,*(&blipping)?1:0);
while(*(&running) || *(&blipping)) // workaround for CodeWarrior!
{
cond.Wait(); // wait for signal by running threads
}
stopit = false;
// cond.Unlock();
post("stop 3");
// --- Here, the threads should have stopped ---
stopit = false; // reset flag
cond.Unlock(); // unlock conditional
}
void thread2::m_blip()
void thread2::m_text()
{
FLEXT_CALLMETHOD(m_textout);
}
void thread2::m_textout()
{
blipping = true;
while(!ShouldExit() && !stopit) {
post(const_cast<char *>(GetString(bliptxt)));
Sleep(0.1f);
post("%i",count);
Sleep(1.f);
}
cond.Lock();
blipping = false;
cond.Signal();
cond.Unlock();
cond.Lock(); // lock conditional
blipping = false; // change state flag
cond.Signal(); // signal changed flag to watiting "stop" method
cond.Unlock(); // unlock conditional
}
\ No newline at end of file
......@@ -23,8 +23,8 @@ CFG=thread2 - Win32 Debug
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
# PROP Scc_ProjName "max/flext/tutorial/thread2"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
......@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /D "FLEXT_THREADS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0xc07 /d "NDEBUG"
......@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib pthreadVC.lib /nologo /dll /machine:I386 /out:"../thread2.dll" /libpath:"..\msvc" /libpath:"..\..\msvc-debug"
# ADD LINK32 kernel32.lib user32.lib pd.lib flext_t-pdwin.lib pthreadVC.lib /nologo /dll /machine:I386 /out:"../thread2.dll" /libpath:"..\msvc" /libpath:"..\..\msvc-t"
!ELSEIF "$(CFG)" == "thread2 - Win32 Debug"
......@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /D "FLEXT_THREADS" /FR /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0xc07 /d "_DEBUG"
......@@ -79,7 +79,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib pthreadVC.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\msvc-debug" /libpath:"..\..\msvc-debug"
# ADD LINK32 kernel32.lib user32.lib pd.lib flext_t-pdwin.lib pthreadVC.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\msvc-debug" /libpath:"..\..\msvc-t-debug"
!ENDIF
......
Supports Markdown
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