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