[PD-cvs] externals/grill/flext/source flqueue.cpp, 1.33, 1.34 flsupport.h, 1.99, 1.100 flthr.cpp, 1.32, 1.33

Thomas Grill xovo at users.sourceforge.net
Tue Dec 6 22:52:28 CET 2005


Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10973/source

Modified Files:
	flqueue.cpp flsupport.h flthr.cpp 
Log Message:
fixed and cleaned up library related stuff, especially co-existance of Max message and DSP library objects
fixes for pthreads version 2
more pthreads V2 fixes
updated docs
update docs
updates for OSX


Index: flqueue.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flqueue.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** flqueue.cpp	7 Jun 2005 14:13:43 -0000	1.33
--- flqueue.cpp	6 Dec 2005 21:52:26 -0000	1.34
***************
*** 24,30 ****
  #ifdef FLEXT_THREADS
  //! Thread id of message queue thread
! flext::thrid_t flext::thrmsgid = 0;
  #endif
  
  #ifdef FLEXT_SHARED
  /*
--- 24,32 ----
  #ifdef FLEXT_THREADS
  //! Thread id of message queue thread
! flext::thrid_t flext::thrmsgid;
  #endif
  
+ static bool qustarted = false;
+ 
  #ifdef FLEXT_SHARED
  /*
***************
*** 300,303 ****
--- 302,306 ----
  {
      thrmsgid = GetThreadId();
+     qustarted = true;
      for(;;) {
          qthrcond.Wait();
***************
*** 309,325 ****
  void flext_base::StartQueue()
  {
!     static bool started = false;
!     if(started) return;
!     else started = true;
! 
  #if FLEXT_QMODE == 1
  #ifdef PERMANENTIDLE
      sys_callback(QTick,NULL,0);
  #endif
  #elif FLEXT_QMODE == 2
      LaunchThread(QWorker,NULL);
  #elif FLEXT_QMODE == 0 && (FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX)
  //    qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick));
      qclk = (t_clock *)(clock_new(NULL,(t_method)QTick));
  #else
  #error Not implemented!
--- 312,328 ----
  void flext_base::StartQueue()
  {
!     if(qustarted) return;
  #if FLEXT_QMODE == 1
  #ifdef PERMANENTIDLE
      sys_callback(QTick,NULL,0);
+     qustarted = true;
  #endif
  #elif FLEXT_QMODE == 2
      LaunchThread(QWorker,NULL);
+     while(!qustarted) Sleep(0.001);
  #elif FLEXT_QMODE == 0 && (FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX)
  //    qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick));
      qclk = (t_clock *)(clock_new(NULL,(t_method)QTick));
+     qustarted = true;
  #else
  #error Not implemented!

Index: flthr.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flthr.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** flthr.cpp	6 Jul 2005 16:08:20 -0000	1.32
--- flthr.cpp	6 Dec 2005 21:52:26 -0000	1.33
***************
*** 39,47 ****
  #include <errno.h>
  
! //! Thread id of system thread
! flext::thrid_t flext::thrid = 0;
  
! //! Thread id of helper thread
! flext::thrid_t flext::thrhelpid = 0;
  
  
--- 39,47 ----
  #include <errno.h>
  
! //! Thread id of system thread - will be initialized in flext::Setup
! flext::thrid_t flext::thrid;
  
! //! Thread id of helper thread - will be initialized in flext::Setup
! flext::thrid_t flext::thrhelpid;
  
  
***************
*** 111,127 ****
  }
  
  
  //! Start helper thread
  bool flext::StartHelper()
  {
- 	if(thrhelpid) return true;
- 	
- 	if(!thrid) {
- 		// system thread has not been set
- 		ERRINTERNAL();
- 		return false;
- 	}
- 
  	bool ok = false;
  #if FLEXT_THREADS == FLEXT_THR_POSIX
  	pthread_attr_t attr;
--- 111,121 ----
  }
  
+ bool initialized = false;
  
  //! Start helper thread
  bool flext::StartHelper()
  {
  	bool ok = false;
+     initialized = false;
  #if FLEXT_THREADS == FLEXT_THR_POSIX
  	pthread_attr_t attr;
***************
*** 129,138 ****
  	pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
  
! 	ok = pthread_create (&thrhelpid,&attr,(void *(*)(void *))ThrHelper,NULL) == 0;
  #elif FLEXT_THREADS == FLEXT_THR_MP
  	if(!MPLibraryIsLoaded())
  		error("Thread library is not loaded");
  	else {
! 		OSStatus ret = MPCreateTask((TaskProc)ThrHelper,NULL,0,0,0,0,0,&thrhelpid);
  		ok = ret == noErr;
  	}
--- 123,134 ----
  	pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
  
!     pthread_t tmp;
! 	ok = pthread_create (&tmp,&attr,(void *(*)(void *))ThrHelper,NULL) == 0;
  #elif FLEXT_THREADS == FLEXT_THR_MP
  	if(!MPLibraryIsLoaded())
  		error("Thread library is not loaded");
  	else {
!         MPTaskID tmp;
! 		OSStatus ret = MPCreateTask((TaskProc)ThrHelper,NULL,0,0,0,0,0,&tmp);
  		ok = ret == noErr;
  	}
***************
*** 146,150 ****
      else {
          // now we have to wait for thread helper to initialize
!         while(!thrhelpid || !thrhelpcond) Sleep(0.001);
  
          // we are ready for threading now!
--- 142,146 ----
      else {
          // now we have to wait for thread helper to initialize
!         while(!initialized) Sleep(0.001);
  
          // we are ready for threading now!
***************
*** 175,178 ****
--- 171,176 ----
  	thrhelpcond = new ThrCond;
  
+     initialized = true;
+ 
  	// helper loop
  	for(;;) {

Index: flsupport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -C2 -d -r1.99 -r1.100
*** flsupport.h	11 Oct 2005 22:22:48 -0000	1.99
--- flsupport.h	6 Dec 2005 21:52:26 -0000	1.100
***************
*** 18,21 ****
--- 18,22 ----
  #include "flstdc.h"
  #include <new>
+ #include <string.h>
  
  /*!	\defgroup FLEXT_SUPPORT Flext support classes
***************
*** 829,833 ****
  	static thrid_t thrhelpid;
  	static thrid_t thrmsgid;
- 	static bool StartHelper();
  	static void ThrHelper(void *);
  
--- 830,833 ----
***************
*** 835,838 ****
--- 835,841 ----
  	static thrid_t thrid;  // the system thread
  
+ private:
+     static bool StartHelper(); // used in flext::Setup()
+ 
  public:
  





More information about the Pd-cvs mailing list