Exemple #1
0
PJ_DEF(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht,
					    pj_timer_entry *entry, 
					    const pj_time_val *delay)
{
    CPjTimerEntry *timerObj;
    pj_status_t status;
    
    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);

    entry->_timer_id = -1;
    
    timerObj = CPjTimerEntry::NewL(ht, entry, delay);
    status = add_entry(ht, timerObj);
    if (status != PJ_SUCCESS) {
	timerObj->Cancel();
	delete timerObj;
	return status;
    }
    
    return PJ_SUCCESS;
}
Exemple #2
0
PJ_DEF(int) pj_timer_heap_cancel( pj_timer_heap_t *ht,
				  pj_timer_entry *entry)
{
    PJ_ASSERT_RETURN(ht && entry, PJ_EINVAL);
    
    if (entry->_timer_id != NULL) {
    	CPjTimerEntry *timerObj = (CPjTimerEntry*) entry->_timer_id;
    	timerObj->Cancel();
    	delete timerObj;
    	entry->_timer_id = NULL;
    	--ht->cur_size;
    	return 1;
    } else {
    	return 0;
    }
}
Exemple #3
0
PJ_DEF(int) pj_timer_heap_cancel( pj_timer_heap_t *ht,
				  pj_timer_entry *entry)
{
    PJ_ASSERT_RETURN(ht && entry, PJ_EINVAL);
    
    if (entry->_timer_id >= 0 && entry->_timer_id < (int)ht->max_size) {
    	CPjTimerEntry *timerObj = ht->entries[entry->_timer_id];
    	if (timerObj) {
    	    timerObj->Cancel();
    	    delete timerObj;
    	    return 1;
    	} else {
    	    return 0;
    	}
    } else {
    	return 0;
    }
}