30 _Thread_local
int _threadnumber;
90 _threadnumber = (int)(uintptr_t) threadnum;
169 while( currjob != newjob )
227 assert(nthreads >= 0);
232 (*thrdpool)->currentid = 0;
233 (*thrdpool)->queuesize = qsize;
234 (*thrdpool)->nthreads = nthreads;
235 (*thrdpool)->blockwhenfull = blockwhenfull;
236 (*thrdpool)->shutdown =
FALSE;
237 (*thrdpool)->queueopen =
TRUE;
241 (*thrdpool)->jobqueue->firstjob = NULL;
242 (*thrdpool)->jobqueue->lastjob = NULL;
243 (*thrdpool)->jobqueue->njobs = 0;
247 (*thrdpool)->currentjobs->firstjob = NULL;
248 (*thrdpool)->currentjobs->lastjob = NULL;
249 (*thrdpool)->currentjobs->njobs = 0;
253 (*thrdpool)->finishedjobs->firstjob = NULL;
254 (*thrdpool)->finishedjobs->lastjob = NULL;
255 (*thrdpool)->finishedjobs->njobs = 0;
267 (*thrdpool)->currworkingthreads = 0;
273 for( i = 0; i < (unsigned)nthreads; i++ )
275 if( thrd_create(&((*thrdpool)->threads[i]),
threadPoolThread, (
void*)i) != thrd_success )
279 _threadnumber = nthreads;
329 assert(newjob != NULL);
330 assert(_threadpool != NULL);
423 if( !(*thrdpool)->queueopen || (*thrdpool)->shutdown )
431 (*thrdpool)->queueopen =
FALSE;
436 while( (*thrdpool)->jobqueue->njobs > 0 )
443 (*thrdpool)->shutdown =
TRUE;
456 for( i = 0; i < (*thrdpool)->nthreads; i++ )
460 if( thrd_join((*thrdpool)->threads[i], &thrdretcode) != thrd_success )
470 assert((*thrdpool)->currentjobs->njobs == 0);
472 assert((*thrdpool)->finishedjobs->njobs == 0);
502 if( currjob != NULL )
504 while( currjob != jobqueue->
lastjob )
506 if( currjob->
jobid == jobid )
512 if( currjob->
jobid == jobid )
549 assert(_threadpool == NULL);
559 assert(_threadpool != NULL);
577 (*job)->jobid =
jobid;
579 (*job)->args = jobarg;
580 (*job)->nextjob = NULL;
591 assert(_threadpool != NULL);
644 if( currjob->
jobid == jobid )
651 retcode = MIN(retcode, currjob->
retcode);
660 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
static SCIP_RETCODE threadPoolThreadRetcode(void *threadnum)
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