static void MAMACALLTYPE
wombatThrottle_timerCB (mamaTimer timer, void *throttle)
{

    /* If mRate == 0, throttle has been deactivated. Finish any remaining 
     * jobs in queue, and wait. If mRate is set again before we finish 
     * purging the queue, we exit the while and don't call wait () */
    while (self->mRate == 0.0
           && wombatThrottle_sendQueuedMessage (throttle)) { }

    self->mMsgsSentThisInterval = 0;
    
    if (list_size (self->mMsgQueue) == 0)     
    {     
        /* Acquire the lock before destroying the timer. */
        wlock_lock (self->mTimerLock);

        /* Destroy the timer. */
        if (self->mTimer != NULL)     
        {     
            mamaTimer_destroy (self->mTimer);     
            self->mTimer = NULL;     
        }     

        /* Release the lock. */
        wlock_unlock (self->mTimerLock);
        
    }     

    wombatThrottle_dispatchMessagesUntilQuota (throttle);

}
mama_status
wombatThrottle_destroy (wombatThrottle throttle)
{
    if (self == NULL)
        return MAMA_STATUS_OK;

    /* Acquire the lock before destroying the timer. */
    wlock_lock (self->mTimerLock);

    /* Destroy the timer. */
    if (self->mTimer != NULL)
    {
        mamaTimer_destroy (self->mTimer);
        self->mTimer = NULL;     
    }     

    /* Release the lock. */
    wlock_unlock (self->mTimerLock);

        /* Destroy the timer lock. */
    if (self->mTimerLock != NULL)
    {
        wlock_destroy (self->mTimerLock);
        self->mTimerLock = NULL;
    }

    
    wombatThrottle_cleanUp (throttle);

    return MAMA_STATUS_OK;
}
Exemple #3
0
static void* waiter(void *parg)
{
	wlock w = parg;
	wlock_lock(w);
	wlock_wait(w);
	wlock_unlock(w);
	return NULL;
}
Exemple #4
0
static void* signaler(void *parg)
{
	wlock w = parg;

	wlock_lock(w);
	wlock_unlock(w);
	wlock_signal(w);
	return NULL;
}
void Lock::lock ()
{
    wlock_lock (mImpl->mLock);
    mImpl->mIsLocked = true;
}
mama_status
wombatThrottle_dispatch (wombatThrottle throttle, 
                         void *owner, 
                         throttleCb actionCb, 
                         void *closure1, 
                         void *closure2,
                         int immediate,
                         wombatThrottleAction *handle)
{
    MsgProperties* info = NULL;
    
    if (self->mRate <= 0.0)
    {
        /* throttle is not in use, execute immediately */
        mama_log (MAMA_LOG_LEVEL_FINEST, "wombatThrottle_dispatch (): "
                  "no throttle; triggering action.");
        actionCb (closure1, closure2);
    }
    else
    {
        list_lock (self->mMsgQueue);
         info = (MsgProperties*)list_allocate_element (self->mMsgQueue);

        /* Acquire the lock before creating the timer. */
        wlock_lock (self->mTimerLock);

        /* Create the timer. */
        if (self->mTimer == NULL)
        {
            mamaTimer_create (&self->mTimer, 
                              self->mQueue,
                              wombatThrottle_timerCB,
                              self->mInterval,
                              self);

            mama_log (MAMA_LOG_LEVEL_FINEST,
                      "wombatThrottle_dispatch (): "
                      "creating throttle timer (%p).", self->mTimer);
        }

        /* Release the lock. */
        wlock_unlock (self->mTimerLock);

        if (info == NULL)
        {
            list_unlock (self->mMsgQueue);
            return (MAMA_STATUS_NOMEM);
        }

        info->mOwner = owner;
        info->mActionCb = actionCb;
        info->mClosure1 = closure1;
        info->mClosure2 = closure2;
        if (handle != NULL)
        {
            *handle = (wombatThrottleAction)info;
        }

        if (immediate)
        {
            list_push_front (self->mMsgQueue, info);
        }
        else
        {
            list_push_back (self->mMsgQueue, info);
        }
        list_unlock (self->mMsgQueue);
    }

    return MAMA_STATUS_OK;
}
Exemple #7
0
status_t fifo_lock(fifo p)
{
    assert(p != NULL);

    return wlock_lock(p->lock);
}