static DaoCallServer* DaoCallServer_New( DaoVmSpace *vms ) { DaoComplex com = {DAO_COMPLEX,0,0,0,1,{0.0,0.0}}; DaoCallServer *self = (DaoCallServer*)dao_malloc( sizeof(DaoCallServer) ); DMutex_Init( & self->mutex ); DCondVar_Init( & self->condv ); DCondVar_Init( & self->condv2 ); DThread_Init( & self->timer ); self->finishing = 0; self->timing = 0; self->total = 0; self->idle = 0; self->stopped = 0; self->threads = DArray_New(0); self->functions = DArray_New(0); self->parameters = DArray_New(0); self->events = DArray_New(0); self->events2 = DArray_New(0); self->waitings = DMap_New(D_VALUE,0); self->pending = DHash_New(0,0); self->active = DHash_New(0,0); self->caches = DArray_New(0); self->vmspace = vms; self->timestamp = com; return self; }
static DaoCallServer* DaoCallServer_New( DaoVmSpace *vms ) { DaoCallServer *self = (DaoCallServer*)dao_malloc( sizeof(DaoCallServer) ); DMutex_Init( & self->mutex ); DCondVar_Init( & self->condv ); DCondVar_Init( & self->condv2 ); DThread_Init( & self->timer ); self->finishing = 0; self->timing = 0; self->total = 0; self->vacant = 0; self->idle = 0; self->stopped = 0; self->threads = DList_New(0); self->functions = DList_New(0); self->parameters = DList_New(0); self->owners = DList_New(0); self->events = DList_New(0); self->events2 = DList_New(0); self->waitings = DMap_New( DAO_DATA_COMPLEX, 0 ); self->pending = DHash_New(0,0); self->active = DHash_New(0,0); self->caches = DList_New(0); self->vmspace = vms; self->timestamp.real = 0.0; self->timestamp.imag = 0.0; return self; }
static DaoCallThread* DaoCallThread_New( DThreadTask func, void *param ) { DaoCallThread *self = (DaoCallThread*)dao_calloc( 1, sizeof(DaoCallThread) ); self->taskFunc = func; self->taskParam = param; DThread_Init( & self->thread ); return self; }
static void DaoThread_SysInit() { thdSpecKey = (dao_thdspec_t)TlsAlloc(); DThread_Init( & mainThread ); mainThread.thdSpecData = DThreadData_New(); mainThread.thdSpecData->thdObject = & mainThread; }
static DaoTaskletThread* DaoTaskletThread_New( DaoTaskletServer *server, DThreadTask func, void *param ) { DaoTaskletThread *self = (DaoTaskletThread*)dao_calloc( 1, sizeof(DaoTaskletThread) ); self->server = server; self->taskFunc = func; self->taskParam = param; self->thdData = & self->thread; DThread_Init( & self->thread ); return self; }
DThread* DThread_GetCurrent() { DThreadData *thdata = DThread_GetSpecific(); if( thdata == NULL ){ thdata = DThreadData_New(); thdata->thdObject = & thdata->thdBuffer; DThread_Init( thdata->thdObject ); } return thdata->thdObject; }
static void DaoThread_SysInit() { thdSpecKey = (dao_thdspec_t)TlsAlloc(); DThread_Init( & mainThread ); mainThread.thdSpecData = (DThreadData*)GlobalAlloc( GPTR, sizeof(DThreadData) ); mainThread.thdSpecData->thdObject = & mainThread; mainThread.thdSpecData->state = 0; TlsSetValue( thdSpecKey, mainThread.thdSpecData ); }
static void DaoThread_SysInit() { DThread *self = & mainThread; pthread_key_create( & thdSpecKey, free ); DThread_Init( self ); self->thdSpecData = DThreadData_New(); self->thdSpecData->thdObject = self; }
void DaoInitThreadSys() { /* DThread object for the main thread, used for join() */ DThread *mainThread = (DThread*)dao_calloc( 1, sizeof(DThread) ); thdSpecKey = (dao_thdspec_t)TlsAlloc(); DThread_Init( mainThread ); mainThread->thdSpecData = (DThreadData*)GlobalAlloc( GPTR, sizeof(DThreadData) ); mainThread->thdSpecData->thdObject = mainThread; mainThread->thdSpecData->state = 0; TlsSetValue( thdSpecKey, mainThread->thdSpecData ); }