30 _Thread_local
int _threadnumber;
90 _threadnumber = (int)(
size_t) threadnum;
169 while( currjob != newjob )
218 assert(nthreads >= 0);
223 (*thrdpool)->currentid = 0;
224 (*thrdpool)->queuesize = qsize;
225 (*thrdpool)->nthreads = nthreads;
226 (*thrdpool)->blockwhenfull = blockwhenfull;
227 (*thrdpool)->shutdown =
FALSE;
228 (*thrdpool)->queueopen =
TRUE;
232 (*thrdpool)->jobqueue->firstjob =
NULL;
233 (*thrdpool)->jobqueue->lastjob =
NULL;
234 (*thrdpool)->jobqueue->njobs = 0;
238 (*thrdpool)->currentjobs->firstjob =
NULL;
239 (*thrdpool)->currentjobs->lastjob =
NULL;
240 (*thrdpool)->currentjobs->njobs = 0;
244 (*thrdpool)->finishedjobs->firstjob =
NULL;
245 (*thrdpool)->finishedjobs->lastjob =
NULL;
246 (*thrdpool)->finishedjobs->njobs = 0;
258 (*thrdpool)->currworkingthreads = 0;
264 for( i = 0; i < nthreads; i++ )
266 if( thrd_create(&((*thrdpool)->threads[i]),
threadPoolThread, (
void*)(
size_t)i) != thrd_success )
270 _threadnumber = nthreads;
320 assert(newjob !=
NULL);
321 assert(_threadpool !=
NULL);
414 if( !(*thrdpool)->queueopen || (*thrdpool)->shutdown )
422 (*thrdpool)->queueopen =
FALSE;
427 while( (*thrdpool)->jobqueue->njobs > 0 )
434 (*thrdpool)->shutdown =
TRUE;
447 for( i = 0; i < (*thrdpool)->nthreads; i++ )
451 if( thrd_join((*thrdpool)->threads[i], &thrdretcode) != thrd_success )
461 assert((*thrdpool)->currentjobs->njobs == 0);
463 assert((*thrdpool)->finishedjobs->njobs == 0);
493 if( currjob !=
NULL )
495 while( currjob != jobqueue->
lastjob )
497 if( currjob->
jobid == jobid )
503 if( currjob->
jobid == jobid )
540 assert(_threadpool ==
NULL);
550 assert(_threadpool !=
NULL);
568 (*job)->jobid =
jobid;
570 (*job)->args = jobarg;
571 (*job)->nextjob =
NULL;
582 assert(_threadpool !=
NULL);
635 if( currjob->
jobid == jobid )
651 assert(prevjob !=
NULL);
SCIP_RETCODE SCIPtpiWaitCondition(SCIP_CONDITION *condition, SCIP_LOCK *lock)
static int threadPoolThread(void *threadnum)
SCIP_CONDITION queuenotempty
enum SCIP_Submitstatus SCIP_SUBMITSTATUS
enum SCIP_Jobstatus SCIP_JOBSTATUS
static SCIP_JOBSTATUS checkJobQueue(SCIP_JOBQUEUE *jobqueue, int jobid)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPtpiBroadcastCondition(SCIP_CONDITION *condition)
SCIP_RETCODE SCIPtpiAcquireLock(SCIP_LOCK *lock)
#define BMSallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPtpiInitCondition(SCIP_LOCK *lock)
SCIP_JOBQUEUE * finishedjobs
static SCIP_RETCODE createThreadPool(SCIP_THREADPOOL **thrdpool, int nthreads, int qsize, SCIP_Bool blockwhenfull)
#define BMSfreeMemory(ptr)
SCIP_CONDITION queueempty
SCIP_RETCODE SCIPtpiCreateJob(SCIP_JOB **job, int jobid, SCIP_RETCODE(*jobfunc)(void *args), void *jobarg)
SCIP_RETCODE SCIPtpiInit(int nthreads, int queuesize, SCIP_Bool blockwhenfull)
SCIP_JOBQUEUE * currentjobs
#define BMSfreeMemoryArray(ptr)
SCIP_RETCODE SCIPtpiReleaseLock(SCIP_LOCK *lock)
the type definitions for the SCIP parallel interface
struct SCIP_Job * nextjob
SCIP_CONDITION queuenotfull
SCIP_RETCODE SCIPtpiExit(void)
int SCIPtpiGetNumThreads(void)
SCIP_RETCODE SCIPtpiInitLock(SCIP_LOCK *lock)
void SCIPtpiDestroyLock(SCIP_LOCK *lock)
void SCIPtpiDestroyCondition(SCIP_LOCK *lock)
static SCIP_RETCODE threadPoolAddWork(SCIP_JOB *newjob, SCIP_SUBMITSTATUS *status)
SCIP_RETCODE SCIPtpiSignalCondition(SCIP_CONDITION *condition)
static SCIP_RETCODE freeThreadPool(SCIP_THREADPOOL **thrdpool, SCIP_Bool finishjobs, SCIP_Bool completequeue)
static void freeJobQueue(SCIP_THREADPOOL *thrdpool)
#define BMSallocMemory(ptr)
SCIP_RETCODE(* jobfunc)(void *args)
SCIP_RETCODE SCIPtpiCollectJobs(int jobid)
#define SCIP_CALL_ABORT(x)
SCIP_RETCODE SCIPtpiSumbitJob(SCIP_JOB *job, SCIP_SUBMITSTATUS *status)
static SCIP_Bool isJobRunning(SCIP_JOBQUEUE *currentjobs, int jobid)
int SCIPtpiGetNewJobID(void)
static void jobQueueAddJob(SCIP_THREADPOOL *threadpool, SCIP_JOB *newjob)
SCIP_CONDITION jobfinished
memory allocation routines