1bfe73648SShuo Chen#include "EventLoop.h" 2bfe73648SShuo Chen#include "EventLoopThread.h" 3bfe73648SShuo Chen#include <stdio.h> 4bfe73648SShuo Chen 5bfe73648SShuo Chenvoid runInThread() 6bfe73648SShuo Chen{ 7bfe73648SShuo Chen printf("runInThread(): pid = %d, tid = %d\n", 8bfe73648SShuo Chen getpid(), muduo::CurrentThread::tid()); 9bfe73648SShuo Chen} 10bfe73648SShuo Chen 11bfe73648SShuo Chenint main() 12bfe73648SShuo Chen{ 13bfe73648SShuo Chen printf("main(): pid = %d, tid = %d\n", 14bfe73648SShuo Chen getpid(), muduo::CurrentThread::tid()); 15bfe73648SShuo Chen 16bfe73648SShuo Chen muduo::EventLoopThread loopThread; 17bfe73648SShuo Chen muduo::EventLoop* loop = loopThread.startLoop(); 18bfe73648SShuo Chen loop->runInLoop(runInThread); 19bfe73648SShuo Chen sleep(1); 20bfe73648SShuo Chen loop->runAfter(2, runInThread); 21bfe73648SShuo Chen sleep(3); 22bfe73648SShuo Chen loop->quit(); 23bfe73648SShuo Chen 24bfe73648SShuo Chen printf("exit main().\n"); 25bfe73648SShuo Chen} 26