#include "coreprof/coreprof.h"
#ifdef RCR
#include "rcr_runtime.h"
+#include "trqueue.h"
#endif
// NOTE: Converting this from a work-stealing strategy
#ifdef RCR
#include "trqueue.h"
-__thread struct trqueue * TRqueue;
+__thread struct trQueue * TRqueue=NULL;
#endif
pthread_attr_t nattr;
pthread_attr_init(&nattr);
pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
- TRqueue=allocTR();
- int status = pthread_create( &(workerDataArray[i].workerThread),
+ if (TRqueue==NULL)
+ TRqueue=allocTR();
+ int status = pthread_create( &thread,
NULL,
workerTR,
(void*) TRqueue);
// this code) will become a worker thread after setup
workerDataArray = RUNMALLOC( sizeof( WorkerData ) * (numWorkers+1) );
+#ifdef RCR
+ //make sure the queue is initialized
+ if (TRqueue==NULL)
+ TRqueue=allocTR();
+#endif
+
for( i = 0; i < numWorkers; ++i ) {
// the original thread is ID 1, start counting from there