threadPool: Replaced errno.h status values with S_pool_* ones

ETIMEDOUT is not provided on MinGW.
This commit is contained in:
Andrew Johnson
2014-08-01 17:55:53 -05:00
parent ab78480d54
commit 6767f5089f
6 changed files with 25 additions and 15 deletions
+1
View File
@@ -24,6 +24,7 @@ Com_SRCS += errSymTbl.c
ERR_S_FILES += $(LIBCOM)/osi/devLib.h
ERR_S_FILES += $(LIBCOM)/as/asLib.h
ERR_S_FILES += $(LIBCOM)/misc/epicsStdlib.h
ERR_S_FILES += $(LIBCOM)/pool/epicsThreadPool.h
ERR_S_FILES += $(SRC)/ioc/db/dbAccessDefs.h
ERR_S_FILES += $(SRC)/ioc/dbStatic/devSup.h
ERR_S_FILES += $(SRC)/ioc/dbStatic/drvSup.h
+1
View File
@@ -49,6 +49,7 @@ extern "C" {
#define M_bucket (525 <<16) /*Bucket Hash*/
#define M_gddFuncTbl (526 <<16) /*gdd jump table*/
#define M_stdlib (527 <<16) /*EPICS Standard library*/
#define M_pool (528 <<16) /*Thread pool*/
epicsShareFunc void epicsShareAPI errSymLookup(long status, char *pBuf, unsigned bufLength);
epicsShareFunc void epicsShareAPI errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum);
+8
View File
@@ -14,6 +14,14 @@
#include <stdio.h>
#include "shareLib.h"
#include "errMdef.h"
#define S_pool_jobBusy (M_pool| 1) /*Job already queued or running*/
#define S_pool_jobIdle (M_pool| 2) /*Job was not queued or running*/
#define S_pool_noPool (M_pool| 3) /*Job not associated with a pool*/
#define S_pool_paused (M_pool| 4) /*Pool not currently accepting jobs*/
#define S_pool_noThreads (M_pool| 5) /*Can't create worker thread*/
#define S_pool_timeout (M_pool| 6) /*Pool still busy after timeout*/
#ifdef __cplusplus
extern "C" {
+8 -8
View File
@@ -125,7 +125,7 @@ int createPoolThread(epicsThreadPool *pool)
&workerMain,
pool);
if (!tid)
return 1;
return S_pool_noThreads;
pool->threadsRunning++;
pool->threadsSleeping++;
@@ -190,7 +190,7 @@ int epicsJobMove(epicsJob *job, epicsThreadPool *newpool)
if (job->queued || job->running) {
epicsMutexUnlock(pool->guard);
return EINVAL;
return S_pool_jobBusy;
}
ellDelete(&pool->owned, &job->jobnode);
@@ -218,18 +218,18 @@ int epicsJobQueue(epicsJob *job)
epicsThreadPool *pool = job->pool;
if (!pool)
return EINVAL;
return S_pool_noPool;
epicsMutexMustLock(pool->guard);
assert(!job->dead);
if (pool->pauseadd) {
ret = EPERM;
ret = S_pool_paused;
goto done;
}
else if (job->freewhendone) {
ret = EINVAL;
ret = S_pool_jobBusy;
goto done;
}
else if (job->queued) {
@@ -279,7 +279,7 @@ int epicsJobQueue(epicsJob *job)
/* oops, we couldn't lazy create our first worker
* so this job would never run!
*/
ret = EAGAIN;
ret = S_pool_noThreads;
job->queued = 0;
/* if threadsRunning==0 then no jobs can be running */
assert(!job->running);
@@ -301,11 +301,11 @@ done:
int epicsJobUnqueue(epicsJob *job)
{
int ret = 1;
int ret = S_pool_jobIdle;
epicsThreadPool *pool = job->pool;
if (!pool)
return EINVAL;
return S_pool_noPool;
epicsMutexMustLock(pool->guard);
+2 -2
View File
@@ -102,7 +102,7 @@ cleanup:
epicsMutexDestroy(pool->guard);
free(pool);
return 0;
return NULL;
}
static
@@ -175,7 +175,7 @@ int epicsThreadPoolWait(epicsThreadPool *pool, double timeout)
cantProceed("epicsThreadPoolWait: failed to wait for Event");
break;
case epicsEventWaitTimeout:
ret = ETIMEDOUT;
ret = S_pool_timeout;
break;
case epicsEventWaitOK:
ret = 0;
+5 -5
View File
@@ -191,7 +191,7 @@ static void cleanupjob2(void* arg, epicsJobMode mode)
if(mode==epicsJobModeCleanup)
epicsJobDestroy(job); /* delete when threadpool is destroyed */
else if(mode==epicsJobModeRun)
testOk1(epicsJobUnqueue(job)==1);
testOk1(epicsJobUnqueue(job)==S_pool_jobIdle);
}
static epicsJobFunction cleanupjobs[3] = {&cleanupjob0,&cleanupjob1,&cleanupjob2};
@@ -341,23 +341,23 @@ void testcancel(void)
/* freeze */
epicsThreadPoolControl(pool, epicsThreadPoolQueueRun, 0);
testOk1(epicsJobUnqueue(job[0])==1); /* not queued yet */
testOk1(epicsJobUnqueue(job[0])==S_pool_jobIdle); /* not queued yet */
epicsJobQueue(job[0]);
testOk1(epicsJobUnqueue(job[0])==0);
testOk1(epicsJobUnqueue(job[0])==1);
testOk1(epicsJobUnqueue(job[0])==S_pool_jobIdle);
epicsThreadSleep(0.01);
epicsJobQueue(job[0]);
testOk1(epicsJobUnqueue(job[0])==0);
testOk1(epicsJobUnqueue(job[0])==1);
testOk1(epicsJobUnqueue(job[0])==S_pool_jobIdle);
epicsThreadPoolControl(pool, epicsThreadPoolQueueRun, 1);
epicsJobQueue(job[1]); /* actually let it run this time */
epicsEventMustWait(cancel[0]);
testOk1(epicsJobUnqueue(job[0])==1);
testOk1(epicsJobUnqueue(job[0])==S_pool_jobIdle);
epicsEventSignal(cancel[1]);
epicsThreadPoolDestroy(pool);