test6.cc revision 354280cf
1354280cfSShuo Chen#include "EventLoop.h" 2354280cfSShuo Chen#include "EventLoopThread.h" 3354280cfSShuo Chen#include <stdio.h> 4354280cfSShuo Chen 5354280cfSShuo Chenvoid runInThread() 6354280cfSShuo Chen{ 7354280cfSShuo Chen printf("runInThread(): pid = %d, tid = %d\n", 8354280cfSShuo Chen getpid(), muduo::CurrentThread::tid()); 9354280cfSShuo Chen} 10354280cfSShuo Chen 11354280cfSShuo Chenint main() 12354280cfSShuo Chen{ 13354280cfSShuo Chen printf("main(): pid = %d, tid = %d\n", 14354280cfSShuo Chen getpid(), muduo::CurrentThread::tid()); 15354280cfSShuo Chen 16354280cfSShuo Chen muduo::EventLoopThread loopThread; 17354280cfSShuo Chen muduo::EventLoop* loop = loopThread.startLoop(); 18354280cfSShuo Chen loop->runInLoop(runInThread); 19354280cfSShuo Chen sleep(1); 20354280cfSShuo Chen loop->runAfter(2, runInThread); 21354280cfSShuo Chen sleep(3); 22354280cfSShuo Chen loop->quit(); 23354280cfSShuo Chen 24354280cfSShuo Chen printf("exit main().\n"); 25354280cfSShuo Chen} 26