1 Star 0 Fork 92

liuzq_cn / handy

forked from yedf / handy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
timer.cc 679 Bytes
一键复制 编辑 原始数据 按行查看 历史
yedf 提交于 2016-03-21 11:43 . add more examples
#include <handy/handy.h>
using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
info("program begin");
base.runAfter(200, [](){
info("a task in runAfter 200ms");
});
base.runAfter(100, [](){
info("a task in runAfter 100ms interval 1000ms");
}, 1000);
TimerId id = base.runAt(time(NULL)*1000+300, [](){
info("a task in runAt now+300 interval 500ms");
}, 500);
base.runAfter(2000, [&](){
info("cancel task of interval 500ms");
base.cancel(id);
});
base.runAfter(3000, [&](){
base.exit();
});
base.loop();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/liuzq-cn/handy.git
git@gitee.com:liuzq-cn/handy.git
liuzq-cn
handy
handy
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891