Example #1
0
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);
}
Example #2
0
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);
}
Example #3
0
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);
}
Example #4
0
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);
}
Example #5
0
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);
}
Example #6
0
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));
}
Example #7
0
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);
}
Example #8
0
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);
}
Example #9
0
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);
}
Example #10
0
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;
    }
}
Example #11
0
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;
    }
}
Example #12
0
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));
}
Example #13
0
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);
}
Example #14
0
void _d_monitorexit(Object *h)
{
    //printf("_d_monitorexit(%p)\n", h);
    assert(h->monitor);
    LeaveCriticalSection(MONPTR(h));
}