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