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