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