test3.cc revision cc7f415c
1cc7f415cSShuo Chen#include "Channel.h" 2cc7f415cSShuo Chen#include "EventLoop.h" 3cc7f415cSShuo Chen 4cc7f415cSShuo Chen#include <stdio.h> 5cc7f415cSShuo Chen#include <sys/timerfd.h> 6cc7f415cSShuo Chen 7cc7f415cSShuo Chenmuduo::EventLoop* g_loop; 8cc7f415cSShuo Chen 9cc7f415cSShuo Chenvoid timeout() 10cc7f415cSShuo Chen{ 11cc7f415cSShuo Chen printf("Timeout!\n"); 12cc7f415cSShuo Chen g_loop->quit(); 13cc7f415cSShuo Chen} 14cc7f415cSShuo Chen 15cc7f415cSShuo Chenint main() 16cc7f415cSShuo Chen{ 17cc7f415cSShuo Chen muduo::EventLoop loop; 18cc7f415cSShuo Chen g_loop = &loop; 19cc7f415cSShuo Chen 20cc7f415cSShuo Chen loop.runAfter(5, timeout); 21cc7f415cSShuo Chen loop.loop(); 22cc7f415cSShuo Chen} 23