PJ_DEF(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay) #endif { pj_status_t status; pj_time_val expires; PJ_ASSERT_RETURN(ht && entry && delay, PJ_EINVAL); PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL); /* Prevent same entry from being scheduled more than once */ PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP); #if PJ_TIMER_DEBUG entry->src_file = src_file; entry->src_line = src_line; #endif pj_gettickcount(&expires); PJ_TIME_VAL_ADD(expires, *delay); lock_timer_heap(ht); status = schedule_entry(ht, entry, &expires); unlock_timer_heap(ht); return status; }
static pj_status_t schedule_w_grp_lock(pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay, pj_bool_t set_id, int id_val, pj_grp_lock_t *grp_lock) #endif { pj_status_t status; pj_time_val expires; PJ_ASSERT_RETURN(ht && entry && delay, PJ_EINVAL); PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL); /* Prevent same entry from being scheduled more than once */ PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP); #if PJ_TIMER_DEBUG entry->src_file = src_file; entry->src_line = src_line; #endif pj_gettickcount(&expires); PJ_TIME_VAL_ADD(expires, *delay); lock_timer_heap(ht); status = schedule_entry(ht, entry, &expires); if (status == PJ_SUCCESS) { if (set_id) entry->id = id_val; entry->_grp_lock = grp_lock; if (entry->_grp_lock) { pj_grp_lock_add_ref(entry->_grp_lock); } } unlock_timer_heap(ht); return status; }