Ejemplo n.º 1
0
void
smcp_handle_timers(smcp_t self) {
	SMCP_EMBEDDED_SELF_HOOK;
	smcp_set_current_instance(self);
	if (self->timers
		&& (smcp_plat_timestamp_to_cms(self->timers->fire_date) <= 0)
	) {
		SMCP_NON_RECURSIVE smcp_timer_t timer;
		SMCP_NON_RECURSIVE smcp_timer_callback_t callback;
		SMCP_NON_RECURSIVE void* context;

		timer = self->timers;
		callback = timer->callback;
		context = timer->context;

		DEBUG_PRINTF("Timer:%p(CTX=%p): Firing...",timer,timer->context);

		timer->cancel = NULL;
		smcp_invalidate_timer(self, timer);
		if (callback) {
			callback(self, context);
		}
	}
#if SMCP_DEBUG_TIMERS
	smcp_dump_all_timers(self);
#endif
}
Ejemplo n.º 2
0
cms_t
smcp_get_timeout(smcp_t self) {
	cms_t ret = SMCP_MAX_TIMEOUT;
	SMCP_EMBEDDED_SELF_HOOK;

	if(self->timers)
		ret = MIN(ret, convert_timeval_to_cms(&self->timers->fire_date));

	ret = MAX(ret, 0);

#if VERBOSE_DEBUG
	if(ret != SMCP_MAX_TIMEOUT) {
		smcp_dump_all_timers(self);
		DEBUG_PRINTF("%p: next timeout = %dms", self, ret);
	}
#endif
	return ret;
}