OpenWrt_Luci_Lua/1_8.sip_push/nebula_sdk/sdk/timer.h

94 lines
2.2 KiB
C
Raw Normal View History

2015-06-13 14:34:38 +00:00
/*
* =====================================================================================
*
* Filename: timer.h
*
* Description: (线)
*
* Version: 1.0
* Created: 2013-08-20
* Revision: none
* Compiler: gcc
*
* Author: xiaoboyu
* Organization:
*
* =====================================================================================
*/
#ifndef __TIMER_HEAP_H__
#define __TIMER_HEAP_H__
#include <stdint.h>
#include "util_rbtree.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct timer_heap_t timer_heap_t;
typedef struct timer_entry
{
int32_t id;
uint8_t in_rbtree; /*是否在红黑树中*/
util_rbtree_node_t rbnode;
void *user_data;
void (*timeout_cb)(timer_heap_t* ht, struct timer_entry *entry);
}timer_entry;
void timer_entry_init(timer_entry* entry, int32_t id, void* user_data, \
void (*timeout_cb)(timer_heap_t* ht, struct timer_entry *entry));
/*
*
* @param limit_size
*/
timer_heap_t* timer_heap_create(int32_t limit_size);
/*
* @brief 256
*/
void set_timer_limit(timer_heap_t *ht, int32_t limit);
/*
* @ref
* @param expires ms
* @return 0 -1
*/
int32_t timer_add( timer_heap_t* ht, timer_entry *entry, uint32_t expires );
/*
* @ref
*/
void timer_del( timer_heap_t* ht, timer_entry* entry );
/*
* @brief (entry必须在定时器内, )
*/
int32_t timer_update(timer_heap_t* ht, timer_entry *entry, uint32_t expires);
/*
* @brief
* @return -1
*/
int32_t timer_earliest_time(timer_heap_t* ht);
/*
* @ref
*/
int32_t timer_size ( timer_heap_t* ht );
/*
* @ref
* @return
*/
int32_t timer_run(timer_heap_t* ht);
void timer_destroy( timer_heap_t* ht);
#ifdef __cplusplus
}
#endif
#endif