1 Star 0 Fork 0

zwhy/oflops

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wc_event.h 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
haris 提交于 2011-02-08 21:09 . integrating work at t-labs with main code
#ifndef WC_EVENT_H
#define WC_EVENT_H
#include <time.h>
#include <sys/time.h>
/***************************************************
* HIGH LEVEL DESCRIPTION
* two ways of using this:
* 1) with SIGALRM and setitimer
* a) call wc_enable_timers(struct wc_queue *) to start the SIGALRM
* for events
* b) call wc_disabled_timers() before adding events, and recall
* wc_enable_timers() to restart handling events
* c) wc_run_next_event() will get called from signal handler;
* don't invoke manually
* 2) with select()
* a) never call wc_enable_timers() -- i.e., leave timers off
* b) call err==wc_get_next_event_delta() to get time until next event
* c) if while err == -1, wc_run_next_event()
* d) timeout=select(*,*,*,time_delta)
* e) if timeout==-1, wc_run_next_event()
*/
struct wc_queue;
struct wc_queue * wc_queue_init(int initSize);
void wc_queue_free(/*@only@*/ struct wc_queue * );
int wc_event_add(struct wc_queue*, void (*fun)(void *), void *arg, struct timeval key);
int wc_event_remove(struct wc_queue *,int id, /*@out@*/ void (**fun)(void *), /*@out@*/ void **arg);
/// select() style
// get the time until the next event
int wc_get_next_event_delta(struct wc_queue *, struct timeval *delta);
// run the next event; returns the id of the event that was run
int wc_run_next_event(struct wc_queue *);
int wc_queue_extract(struct wc_queue *pq , int *, struct timeval * key, void (**fun)(void *), void **arg);
void *event_loop(void *param);
/******************
* Don't use... slow on planetlab
/// SIGALRM style
// enable/disable SIGALRM lock; starts disabled
void wc_disable_timers(struct wc_queue *);
void wc_enable_timers(struct wc_queue *);
*/
void wc_queue_unit_test();
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yinfuxing/oflops.git
git@gitee.com:yinfuxing/oflops.git
yinfuxing
oflops
oflops
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385