test6.cc revision 40161064
140161064SShuo Chen#include "EventLoop.h" 240161064SShuo Chen#include "EventLoopThread.h" 340161064SShuo Chen#include <stdio.h> 440161064SShuo Chen 540161064SShuo Chenvoid runInThread() 640161064SShuo Chen{ 740161064SShuo Chen printf("runInThread(): pid = %d, tid = %d\n", 840161064SShuo Chen getpid(), muduo::CurrentThread::tid()); 940161064SShuo Chen} 1040161064SShuo Chen 1140161064SShuo Chenint main() 1240161064SShuo Chen{ 1340161064SShuo Chen printf("main(): pid = %d, tid = %d\n", 1440161064SShuo Chen getpid(), muduo::CurrentThread::tid()); 1540161064SShuo Chen 1640161064SShuo Chen muduo::EventLoopThread loopThread; 1740161064SShuo Chen muduo::EventLoop* loop = loopThread.startLoop(); 1840161064SShuo Chen loop->runInLoop(runInThread); 1940161064SShuo Chen sleep(1); 2040161064SShuo Chen loop->runAfter(2, runInThread); 2140161064SShuo Chen sleep(3); 2240161064SShuo Chen loop->quit(); 2340161064SShuo Chen 2440161064SShuo Chen printf("exit main().\n"); 2540161064SShuo Chen} 26