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