From d62e56f4df9594f72ce501f5e19c974fd18e7295 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 22 Oct 2002 23:07:10 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r186, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=187 --- externals/grill/flext/tutorial/thread1/main.cpp | 79 ++++++++++++++++ externals/grill/flext/tutorial/thread1/thread1.cw | Bin 0 -> 89119 bytes externals/grill/flext/tutorial/thread1/thread1.dsp | 104 +++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 externals/grill/flext/tutorial/thread1/main.cpp create mode 100644 externals/grill/flext/tutorial/thread1/thread1.cw create mode 100644 externals/grill/flext/tutorial/thread1/thread1.dsp (limited to 'externals/grill/flext/tutorial/thread1') diff --git a/externals/grill/flext/tutorial/thread1/main.cpp b/externals/grill/flext/tutorial/thread1/main.cpp new file mode 100644 index 00000000..878cef76 --- /dev/null +++ b/externals/grill/flext/tutorial/thread1/main.cpp @@ -0,0 +1,79 @@ +/* +flext tutorial - threads 1 + +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. + +------------------------------------------------------------------------- + +This shows an example of a method running as a thread +*/ + +// define FLEXT_THREADS for thread usage. Flext must also have been compiled with that defined! +#ifndef FLEXT_THREADS +#define FLEXT_THREADS +#endif + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 301) +#error You need at least flext version 0.3.1 +#endif + + +class thread1: + public flext_base +{ + FLEXT_HEADER(thread1,flext_base) + +public: + thread1(); + +protected: + void m_start(); // method function + +private: + // define threaded callback for method m_start (with boolean argument) + // the same syntax as with FLEXT_CALLBACK is used here + FLEXT_THREAD(m_start); +}; + +FLEXT_NEW("thread1",thread1) + + + +thread1::thread1() +{ + AddInAnything(); + AddOutInt(); + SetupInOut(); // set up inlets and outlets + + FLEXT_ADDBANG(0,m_start); // register method +} + +void thread1::m_start() +{ + // Please note that this functions needs about 10 seconds to complete + // Without threads it would block the real-time system + + // Okay, that functionality would be far more elegant with timers + // ... but hey, it's a demo! + + for(int i = 0; i < 20 && !ShouldExit(); ++i) { + ToOutInt(0,i); // output loop count + + // wait for half a second + for(int j = 0; j < 5 && !ShouldExit(); ++j) Sleep(0.1f); + // note: we shall not block a thread for a longer time. + // The system might want to destroy the object in the meantime and + // expects thread termination. + // Flext waits for 1 second by default, then it aborts the thread brutally + } + + // output a final zero + ToOutInt(0,0); +} + + + diff --git a/externals/grill/flext/tutorial/thread1/thread1.cw b/externals/grill/flext/tutorial/thread1/thread1.cw new file mode 100644 index 00000000..b26ff18b Binary files /dev/null and b/externals/grill/flext/tutorial/thread1/thread1.cw differ diff --git a/externals/grill/flext/tutorial/thread1/thread1.dsp b/externals/grill/flext/tutorial/thread1/thread1.dsp new file mode 100644 index 00000000..7ef7ca52 --- /dev/null +++ b/externals/grill/flext/tutorial/thread1/thread1.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="thread1" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=thread1 - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "thread1.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "thread1.mak" CFG="thread1 - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "thread1 - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "thread1 - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "thread1" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "thread1 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "msvc" +# PROP Intermediate_Dir "msvc" +# 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 /GR- /GX- /O2 /I "..\..\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /D "FLEXT_THREADS" /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" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_t-pdwin.lib pthreadVC.lib /nologo /dll /machine:I386 /out:"../msvc/thread1.dll" /libpath:"..\..\pd-msvc" + +!ELSEIF "$(CFG)" == "thread1 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc-debug" +# PROP Intermediate_Dir "msvc-debug" +# 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 "..\..\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NT" /D "PD" /D "FLEXT_THREADS" /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" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# 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_td-pdwin.lib pthreadVC.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "thread1 - Win32 Release" +# Name "thread1 - Win32 Debug" +# Begin Source File + +SOURCE=.\main.cpp + +!IF "$(CFG)" == "thread1 - Win32 Release" + +# ADD CPP /GR- + +!ELSEIF "$(CFG)" == "thread1 - Win32 Debug" + +!ENDIF + +# End Source File +# End Target +# End Project -- cgit v1.2.1