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