cleanup callback and callback*Test

This commit is contained in:
Michael Davidsaver
2014-09-16 18:55:27 -04:00
parent 7f7e63fee1
commit b3c1fef110
3 changed files with 25 additions and 4 deletions

View File

@@ -169,6 +169,7 @@ static void callbackTask(void *arg)
}
shutdown:
mySet->threadsRunning--;
taskwdRemove(0);
epicsEventSignal(startStopEvent);
}
@@ -180,16 +181,24 @@ void callbackShutdown(void)
if (cbCtl == ctlExit) return;
cbCtl = ctlExit;
/* sequential shutdown of workers */
for (i = 0; i < NUM_CALLBACK_PRIORITIES; i++) {
while (callbackQueue[i].threadsRunning--) {
int ok = epicsRingPointerPush(callbackQueue[i].queue, &exitCallback);
epicsEventSignal(callbackQueue[i].semWakeUp);
if (ok) epicsEventWait(startStopEvent);
while (callbackQueue[i].threadsRunning) {
if(epicsRingPointerPush(callbackQueue[i].queue, &exitCallback)) {
epicsEventSignal(callbackQueue[i].semWakeUp);
epicsEventWait(startStopEvent);
} else {
epicsThreadSleep(0.05);
}
}
assert(callbackQueue[i].threadsRunning==0);
epicsEventDestroy(callbackQueue[i].semWakeUp);
epicsRingPointerDelete(callbackQueue[i].queue);
}
epicsTimerQueueRelease(timerQueue);
epicsEventDestroy(startStopEvent);
startStopEvent = NULL;
memset(callbackQueue, 0, sizeof(callbackQueue));
}
void callbackInit(void)

View File

@@ -180,5 +180,11 @@ MAIN(callbackParallelTest)
printStats(timeError[1], "MID");
printStats(timeError[2], "HIGH");
for (i = 0; i < NCALLBACKS ; i++) {
free(pcbt[i]);
}
callbackShutdown();
return testDone();
}

View File

@@ -177,5 +177,11 @@ MAIN(callbackTest)
printStats(timeError[1], "MID");
printStats(timeError[2], "HIGH");
for (i = 0; i < NCALLBACKS ; i++) {
free(pcbt[i]);
}
callbackShutdown();
return testDone();
}