1 Star 0 Fork 0

zwhy/oflops

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
timer_event.c 957 Bytes
一键复制 编辑 原始数据 按行查看 历史
haris 提交于 2011-02-08 21:09 . integrating work at t-labs with main code
#include <sys/time.h>
#include "timer_event.h"
int timer_get_next_event(struct oflops_context *ctx)
{
struct timeval tv;
int ret;
ret=wc_get_next_event_delta(ctx->timers, &tv);
if(ret == 0)
{
return tv.tv_sec * 1000000 + tv.tv_usec; // next event
}
else if(ret == -1)
return 1000000; // no events; just say 1 sec
else
return -1; // next event timer already passed...
}
int timer_run_next_event(struct oflops_context *ctx)
{
void (* func)(void *);
void * val;
int id;
struct timeval t;
int err;
timer_event te;
err = wc_queue_extract(ctx->timers, &id, &t, &func, &val);
te.timer_id = id;
te.arg = val;
te.sched_time = t;
// func is ignored by oflops
ctx->curr_test->handle_timer_event(ctx, &te);
return 0;
}
int timer_init(struct oflops_context *ctx)
{
if(ctx->timers)
wc_queue_free(ctx->timers);
ctx->timers = wc_queue_init(10); // 10 == initial size; gets dynamically resized so it don't matter
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yinfuxing/oflops.git
git@gitee.com:yinfuxing/oflops.git
yinfuxing
oflops
oflops
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385