28 memset(opts, 0,
sizeof(*opts));
44 errlogMessage(
"Error: epicsThreadPoolCreate() options provided, but not initialized");
48 pool = calloc(1,
sizeof(*pool));
53 memcpy(&pool->
conf, opts,
sizeof(*opts));
80 errlogPrintf(
"Error: Unable to create any threads for thread pool\n");
85 errlogPrintf(
"Warning: Unable to create all threads for thread pool (%u/%u)\n",
129 int wakeup = jobs > wakeable ? wakeable : jobs;
155 epicsThreadPoolControlImpl(pool, opt, val);
174 cantProceed(
"epicsThreadPoolWait: failed to wait for Event");
271 fprintf(fd,
"Thread Pool with %u/%u threads\n" 272 " running %d jobs with %u threads\n",
278 fprintf(fd,
" Inhibit queueing\n");
280 fprintf(fd,
" Pause workers\n");
282 fprintf(fd,
" Shutdown in progress\n");
287 fprintf(fd,
" job %p func: %p, arg: %p ",
291 fprintf(fd,
"Queued ");
293 fprintf(fd,
"Running ");
295 fprintf(fd,
"Free ");
323 void sharedPoolsInit(
void* unused)
epicsEventId workerWakeup
void epicsThreadPoolControl(epicsThreadPool *pool, epicsThreadPoolOption opt, unsigned int val)
#define CHECKCOUNT(pPool)
void epicsThreadPoolConfigDefaults(epicsThreadPoolConfig *opts)
#define assert(exp)
Declare that a condition should be true.
#define ellCount(PLIST)
Report the number of nodes in a list.
void epicsStdCall epicsMutexDestroy(epicsMutexId pmutexNode)
Destroy an epicsMutex semaphore.
#define epicsThreadPriorityMedium
#define CONTAINER(ptr, structure, member)
Find parent object from a member pointer.
void epicsThreadPoolReport(epicsThreadPool *pool, FILE *fd)
unsigned int freewhendone
int createPoolThread(epicsThreadPool *pool)
#define epicsEventWait(ID)
ELLNODE * ellGet(ELLLIST *pList)
Deletes and returns the first node from a list.
LIBCOM_API void epicsThreadPoolReleaseShared(epicsThreadPool *pool)
#define epicsMutexMustCreate()
Create an epicsMutex semaphore for use from C code.
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout(epicsEventId id, double timeOut)
Wait an the event or until the specified timeout period is over.
#define ELLLIST_INIT
Value of an empty list.
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Miscellaneous macro definitions.
epicsThreadPool * epicsThreadPoolCreate(epicsThreadPoolConfig *opts)
LIBCOM_API unsigned int epicsStdCall epicsThreadGetStackSize(epicsThreadStackSizeClass size)
LIBCOM_API void epicsEventMustWait(epicsEventId id)
Wait for an event (see epicsEventWait()).
void epicsThreadPoolDestroy(epicsThreadPool *pool)
unsigned int initialThreads
unsigned int threadsWaking
A doubly-linked list library.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define ellNext(PNODE)
Find the next node in list.
LIBCOM_API int epicsThreadGetCPUs(void)
#define EPICS_THREAD_ONCE_INIT
LIBCOM_API epicsThreadPool * epicsThreadPoolGetShared(epicsThreadPoolConfig *opts)
unsigned int threadsAreAwake
#define epicsEventSignal(ID)
A synonym for epicsEventTrigger().
LIBCOM_API epicsThreadBooleanStatus epicsStdCall epicsThreadLowestPriorityLevelAbove(unsigned int priority, unsigned *pPriorityJustAbove)
APIs for the epicsMutex mutual exclusion semaphore.
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
unsigned int workerPriority
LIBCOM_API void epicsEventDestroy(epicsEventId id)
Destroy an epicsEvent and any resources it holds.
epicsEventId shutdownEvent
epicsThreadPoolConfig conf
unsigned int observerCount
int errlogPrintf(const char *pFormat,...)
APIs for the epicsEvent binary semaphore.
#define epicsThreadPriorityCAServerHigh
unsigned int threadsRunning
int epicsThreadPoolWait(epicsThreadPool *pool, double timeout)
int errlogMessage(const char *message)
#define ellInit(PLIST)
Initialize a list type.
#define epicsEventWaitOK
Old name provided for backwards compatibility.
#define epicsMutexCreate()
Create an epicsMutex semaphore for use from C code.
LIBCOM_API void cantProceed(const char *msg,...)
unsigned int threadsSleeping
void ellConcat(ELLLIST *pDstList, ELLLIST *pAddList)
Concatenates a list to the end of another list. The list to be added is left empty. Either list (or both) can be empty at the beginning of the operation.
Routines for code that can't continue or return after an error.
C++ and C descriptions for a thread.
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
#define epicsEventWaitError
Old name provided for backwards compatibility.
LIBCOM_API epicsEventId epicsEventCreate(epicsEventInitialState initialState)
Create an epicsEvent for use from C code, or return NULL.
epicsEventId observerWakeup
unsigned int epicsThreadPoolNThreads(epicsThreadPool *pool)
#define ellFirst(PLIST)
Find the first node in list.