test6.cc revision 9807252e
19807252eSShuo Chen#include "EventLoop.h" 29807252eSShuo Chen#include "EventLoopThread.h" 39807252eSShuo Chen#include <stdio.h> 49807252eSShuo Chen 59807252eSShuo Chenvoid runInThread() 69807252eSShuo Chen{ 79807252eSShuo Chen printf("runInThread(): pid = %d, tid = %d\n", getpid(), muduo::CurrentThread::tid()); 89807252eSShuo Chen} 99807252eSShuo Chen 109807252eSShuo Chenint main() 119807252eSShuo Chen{ 129807252eSShuo Chen printf("main(): pid = %d, tid = %d\n", getpid(), muduo::CurrentThread::tid()); 139807252eSShuo Chen 149807252eSShuo Chen muduo::EventLoopThread loopThread; 159807252eSShuo Chen muduo::EventLoop* loop = loopThread.startLoop(); 169807252eSShuo Chen loop->runInLoop(runInThread); 179807252eSShuo Chen sleep(1); 189807252eSShuo Chen loop->runAfter(2, runInThread); 199807252eSShuo Chen sleep(3); 209807252eSShuo Chen loop->quit(); 219807252eSShuo Chen 229807252eSShuo Chen printf("exit main().\n"); 239807252eSShuo Chen} 24