static void createPublisher () { mamaDQPublisherManagerCallbacks managerCallback; memset(&managerCallback, 0, sizeof(managerCallback)); managerCallback.onCreate = subscriptionHandlerOnCreateCb; managerCallback.onError =subscriptionHandlerOnErrorCb; managerCallback.onNewRequest =subscriptionHandlerOnNewRequestCb; managerCallback.onRequest =subscriptionHandlerOnRequestCb; managerCallback.onRefresh =subscriptionHandlerOnRefreshCb; srand ( time(NULL) ); mamaDQPublisherManager_allocate (&gDQPubManager); mamaDQPublisherManager_create (gDQPubManager, gPubTransport, gPubDefaultQueue, &managerCallback, gPubSource, "_MD", NULL); mamaDQPublisherManager_enableSendTime(gDQPubManager, 1); if (gSendSync) { mamaTimer_create (&gSyncTimer, gPubDefaultQueue, syncCallback, 15, gDQPubManager); } }
mama_status mamaStatsGenerator_setQueue (mamaStatsGenerator statsGenerator, mamaQueue queue) { mama_status status = MAMA_STATUS_OK; mamaStatsGeneratorImpl* impl = (mamaStatsGeneratorImpl*)statsGenerator; if (impl == NULL) return MAMA_STATUS_NULL_ARG; if (!(impl->mQueue = queue)) { mama_log (MAMA_LOG_LEVEL_ERROR, "mamaStatsGenerator_setQueue(): " "No queue specified"); return MAMA_STATUS_NULL_ARG; } if (MAMA_STATUS_OK != (status = mamaTimer_create (&impl->mReportTimer, impl->mQueue, mamaStatsGenerator_onReportTimer, impl->mReportInterval, (mamaStatsGenerator)impl))) { return status; } return status; }
static void start_timed_publish (void) { mamaTimer_create (&gPubTimer, gPubDefaultQueue, pubCallback, gTimeInterval, NULL); }
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; }