if(!gManager)xabort("AsyncWorker_requestWork() called without calling AsyncWorker_init() first");
if(!work)xabort("AsyncWorker_requestWork() called without a valid function pointer");//need to catch this condition to stop users from terminating our worker threads
//find an unused worker
if(!gManager->idleWorkerCount)returnNULL;
AsyncJob*worker=NULL;
for(inti=0;i<gManager->workerCount;i++)
{
if(!gManager->communicators[i].inUse)
{
worker=&gManager->communicators[i];
break;
}
}
if(!worker)xabort("internal error: idleWorkerCount is not in sync with the worker states, please report this bug");