19a1e991dSShuo Chen#include "EventLoop.h" 29a1e991dSShuo Chen#include "EventLoopThread.h" 39a1e991dSShuo Chen#include <stdio.h> 49a1e991dSShuo Chen 59a1e991dSShuo Chenvoid runInThread() 69a1e991dSShuo Chen{ 7a20e676dSShuo Chen printf("runInThread(): pid = %d, tid = %d\n", 8a20e676dSShuo Chen getpid(), muduo::CurrentThread::tid()); 99a1e991dSShuo Chen} 109a1e991dSShuo Chen 119a1e991dSShuo Chenint main() 129a1e991dSShuo Chen{ 13a20e676dSShuo Chen printf("main(): pid = %d, tid = %d\n", 14a20e676dSShuo Chen getpid(), muduo::CurrentThread::tid()); 159a1e991dSShuo Chen 169a1e991dSShuo Chen muduo::EventLoopThread loopThread; 179a1e991dSShuo Chen muduo::EventLoop* loop = loopThread.startLoop(); 189a1e991dSShuo Chen loop->runInLoop(runInThread); 199a1e991dSShuo Chen sleep(1); 209a1e991dSShuo Chen loop->runAfter(2, runInThread); 219a1e991dSShuo Chen sleep(3); 229a1e991dSShuo Chen loop->quit(); 239a1e991dSShuo Chen 249a1e991dSShuo Chen printf("exit main().\n"); 259a1e991dSShuo Chen} 26