tpi_tnycthrd.c
Go to the documentation of this file.
33/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
44#define SCIPtnyInitLock(lock) ( mtx_init((lock), mtx_plain) == thrd_success ? SCIP_OKAY : SCIP_ERROR )
50#define SCIPtnyInitCondition(condition) ( cnd_init(condition) == thrd_success ? SCIP_OKAY : SCIP_ERROR )
52#define SCIPtnySignalCondition(condition) ( cnd_signal(condition) == thrd_success ? SCIP_OKAY : SCIP_ERROR )
53#define SCIPtnyBroadcastCondition(condition) ( cnd_broadcast(condition) == thrd_success ? SCIP_OKAY : SCIP_ERROR )
54#define SCIPtnyWaitCondition(condition, lock) ( cnd_wait((condition), (lock)) == thrd_success ? SCIP_OKAY: SCIP_ERROR )
171 /* if we want to wait when the queue is full, then we broadcast that the queue can now take new jobs */
340 /* @todo we want to work out what to do with a full job queue. Is there a problem if the limit is hit? */
341 /* @note it is important to have a queuesize. This will stop the code submitting infinitely many jobs. */
358 /* signalling to all threads that the queue has jobs using the signal instead of broadcast because only one thread
385 /* Wait until the job queue is not full. If the queue is closed or the thread pool is shut down, then stop waiting. */
386 /* @todo this needs to be checked. It is possible that a job can be submitted and then the queue is closed or the
388 while( _threadpool->jobqueue->njobs == _threadpool->queuesize && !(_threadpool->shutdown || !_threadpool->queueopen) )
393 /* if the thread pool is shut down or the queue is closed, then we need to leave the job submission */
474 /* if the jobs in the queue should be completed, then we wait until the queueempty condition is set */
510 /* Freeing the current jobs list. This assumes that all jobs complete before the tpi is closed. */
646 /* the job id must be set before submitting the job. The submitter controls whether a new id is required. */
666 while( isJobRunning(_threadpool->currentjobs, jobid) || isJobRunning(_threadpool->jobqueue, jobid) )
859 (void) SCIPsnprintf(name, namesize, "TinyCThread %d.%d", TINYCTHREAD_VERSION_MAJOR, TINYCTHREAD_VERSION_MINOR);
870 (void) SCIPsnprintf(desc, descsize, "small portable implementation of the C11 threads API (tinycthread.github.io)");
memory allocation routines
public methods for message output
public data structures and miscellaneous methods
Definition: tpi_openmp.c:63
Definition: tpi_openmp.c:83
Definition: tpi_openmp.c:73
Definition: tpi_openmp.c:57
Definition: tpi_tnycthrd.c:94
the type definitions for the SCIP parallel interface
static SCIP_RETCODE threadPoolAddWork(SCIP_JOB *newjob, SCIP_SUBMITSTATUS *status)
Definition: tpi_tnycthrd.c:367
static SCIP_JOBSTATUS checkJobQueue(SCIP_JOBQUEUE *jobqueue, int jobid)
Definition: tpi_tnycthrd.c:535
SCIP_RETCODE SCIPtpiWaitCondition(SCIP_CONDITION *condition, SCIP_LOCK *lock)
Definition: tpi_tnycthrd.c:827
SCIP_RETCODE SCIPtpiCreateJob(SCIP_JOB **job, int jobid, SCIP_RETCODE(*jobfunc)(void *args), void *jobarg)
Definition: tpi_tnycthrd.c:606
static SCIP_RETCODE threadPoolThreadRetcode(void *threadnum)
Definition: tpi_tnycthrd.c:123
SCIP_RETCODE SCIPtpiSignalCondition(SCIP_CONDITION *condition)
Definition: tpi_tnycthrd.c:804
static SCIP_RETCODE createThreadPool(SCIP_THREADPOOL **thrdpool, int nthreads, int qsize, SCIP_Bool blockwhenfull)
Definition: tpi_tnycthrd.c:259
static void jobQueueAddJob(SCIP_THREADPOOL *threadpool, SCIP_JOB *newjob)
Definition: tpi_tnycthrd.c:335
SCIP_RETCODE SCIPtpiBroadcastCondition(SCIP_CONDITION *condition)
Definition: tpi_tnycthrd.c:815
SCIP_RETCODE SCIPtpiSubmitJob(SCIP_JOB *job, SCIP_SUBMITSTATUS *status)
Definition: tpi_tnycthrd.c:639
static SCIP_Bool isJobRunning(SCIP_JOBQUEUE *currentjobs, int jobid)
Definition: tpi_tnycthrd.c:562
void SCIPtpiGetLibraryDesc(char *desc, int descsize)
Definition: tpi_tnycthrd.c:863
void SCIPtpiDestroyCondition(SCIP_CONDITION **condition)
Definition: tpi_tnycthrd.c:795
void SCIPtpiGetLibraryName(char *name, int namesize)
Definition: tpi_tnycthrd.c:852
static SCIP_RETCODE freeThreadPool(SCIP_THREADPOOL **thrdpool, SCIP_Bool finishjobs, SCIP_Bool completequeue)
Definition: tpi_tnycthrd.c:449
SCIP_RETCODE SCIPtpiInitCondition(SCIP_CONDITION **condition)
Definition: tpi_tnycthrd.c:781
SCIP_RETCODE SCIPtpiInit(int nthreads, int queuesize, SCIP_Bool blockwhenfull)
Definition: tpi_tnycthrd.c:582