void subscription_handler(struct octopus_binding *b, subscription_t id, uint64_t fn, octopus_mode_t mode, char *record, uint64_t st) { // XXX: Probably send some offset around and use 32bit in flounder? // XXX: The casting to uintptr_t is for 32-bit archs subscription_handler_fn handler_fn = (subscription_handler_fn)(uintptr_t)fn; void* state = (void*)(uintptr_t)st; if (handler_fn != NULL) { handler_fn(mode, record, state); } else { fprintf(stderr, "Incoming subscription(%"PRIu64") for %s with unset handler function.", id, record); free(record); } }
void SelfDrainingQueue::timerHandler( void ) { dprintf( D_FULLDEBUG, "Inside SelfDrainingQueue::timerHandler() for %s\n", name ); if( queue.IsEmpty() ) { dprintf( D_FULLDEBUG, "SelfDrainingQueue %s is empty, " "timerHandler() has nothing to do\n", name ); cancelTimer(); return; } int count; for( count=0; count<m_count_per_interval && !queue.IsEmpty(); count++ ) { ServiceData* d = NULL; queue.dequeue(d); SelfDrainingHashItem hash_item(d); m_hash.remove(hash_item); if( handler_fn ) { handler_fn( d ); } else if( handlercpp_fn && service_ptr ) { (service_ptr->*handlercpp_fn)( d ); } } if( queue.IsEmpty() ) { dprintf( D_FULLDEBUG, "SelfDrainingQueue %s is empty, not resetting timer\n", name ); cancelTimer(); } else { // if there's anything left in the queue, reset our timer dprintf( D_FULLDEBUG, "SelfDrainingQueue %s still has %d element(s), " "resetting timer\n", name, queue.Length() ); resetTimer(); } }