void _d_monitor_unlock(Object *h) { //printf("+_d_monitor_release(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); pthread_mutex_unlock(MONPTR(h)); //printf("-_d_monitor_release(%p)\n", h); }
void _d_monitorexit(Object *h) { //printf("+_d_monitorexit(%p)\n", h); assert(h->monitor); pthread_mutex_unlock(MONPTR(h)); //printf("-_d_monitorexit(%p)\n", h); }
int _d_monitor_lock(Object *h) { //printf("+_d_monitor_acquire(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); pthread_mutex_lock(MONPTR(h)); //printf("-_d_monitor_acquire(%p)\n", h); }
int _d_monitor_lock(Object *h) { //printf("+_d_monitor_acquire(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); EnterCriticalSection(MONPTR(h)); //printf("-_d_monitor_acquire(%p)\n", h); }
void _d_monitor_unlock(Object *h) { //printf("+_d_monitor_release(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); LeaveCriticalSection(MONPTR(h)); //printf("-_d_monitor_release(%p)\n", h); }
void *_d_monitorget(Object *h) { if (!h->monitor) { Monitor *cs; cs = (Monitor *)calloc(sizeof(Monitor), 1); assert(cs); pthread_mutex_lock(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { h->monitor = (void *)cs; #ifndef PTHREAD_MUTEX_ALREADY_RECURSIVE pthread_mutex_init(&cs->mon, & _monitors_attr); #else pthread_mutex_init(&cs->mon, NULL); #endif cs = NULL; } pthread_mutex_unlock(&_monitor_critsec); if (cs) // if we didn't use it free(cs); } return ((void *) MONPTR(h)); }
void _d_monitorenter(Object *h) { //printf("_d_monitorenter(%p), %p\n", h, h->monitor); if (!h->monitor) { Monitor *cs; cs = (Monitor *)calloc(sizeof(Monitor), 1); assert(cs); pthread_mutex_lock(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { h->monitor = (void *)cs; #ifndef PTHREAD_MUTEX_ALREADY_RECURSIVE pthread_mutex_init(&cs->mon, & _monitors_attr); #else pthread_mutex_init(&cs->mon, NULL); #endif cs = NULL; } pthread_mutex_unlock(&_monitor_critsec); if (cs) // if we didn't use it free(cs); } //printf("-_d_monitorenter(%p)\n", h); pthread_mutex_lock(MONPTR(h)); //printf("-_d_monitorenter(%p)\n", h); }
void _d_monitor_destroy(Object *h) { //printf("+_d_monitor_destroy(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); pthread_mutex_destroy(MONPTR(h)); free((void *)h->monitor); h->monitor = NULL; //printf("-_d_monitor_destroy(%p)\n", h); }
void _d_monitor_destroy(Object *h) { //printf("+_d_monitor_destroy(%p)\n", h); assert(h && h->monitor && !(((Monitor*)h->monitor)->impl)); DeleteCriticalSection(MONPTR(h)); free((void *)h->monitor); h->monitor = NULL; //printf("-_d_monitor_destroy(%p)\n", h); }
void _d_monitorrelease(Object *h) { if (h->monitor) { _d_notify_release(h); pthread_mutex_destroy(MONPTR(h)); // We can improve this by making a free list of monitors free((void *)h->monitor); h->monitor = NULL; } }
void _d_monitorrelease(Object *h) { if (h->monitor) { _d_notify_release(h); DeleteCriticalSection(MONPTR(h)); // We can improve this by making a free list of monitors free((void *)h->monitor); h->monitor = NULL; } }
void *_d_monitorget(Object *h) { if (!h->monitor) { Monitor *cs; cs = (Monitor *)calloc(sizeof(Monitor), 1); assert(cs); EnterCriticalSection(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { h->monitor = (void *)cs; InitializeCriticalSection(&cs->mon); cs = NULL; } LeaveCriticalSection(&_monitor_critsec); if (cs) // if we didn't use it free(cs); } return ((void *) MONPTR(h)); }
void _d_monitorenter(Object *h) { //printf("_d_monitorenter(%p), %p\n", h, h->monitor); if (!h->monitor) { Monitor *cs; cs = (Monitor *)calloc(sizeof(Monitor), 1); assert(cs); EnterCriticalSection(&_monitor_critsec); if (!h->monitor) // if, in the meantime, another thread didn't set it { h->monitor = (void *)cs; InitializeCriticalSection(&cs->mon); cs = NULL; } LeaveCriticalSection(&_monitor_critsec); if (cs) // if we didn't use it free(cs); } //printf("-_d_monitorenter(%p)\n", h); EnterCriticalSection(MONPTR(h)); //printf("-_d_monitorenter(%p)\n", h); }
void _d_monitorexit(Object *h) { //printf("_d_monitorexit(%p)\n", h); assert(h->monitor); LeaveCriticalSection(MONPTR(h)); }