test1.cc revision 354280cf
1354280cfSShuo Chen#include "EventLoop.h" 2354280cfSShuo Chen#include "thread/Thread.h" 3354280cfSShuo Chen#include <stdio.h> 4354280cfSShuo Chen 5354280cfSShuo Chenvoid threadFunc() 6354280cfSShuo Chen{ 7354280cfSShuo Chen printf("threadFunc(): pid = %d, tid = %d\n", 8354280cfSShuo Chen getpid(), muduo::CurrentThread::tid()); 9354280cfSShuo Chen 10354280cfSShuo Chen muduo::EventLoop loop; 11354280cfSShuo Chen loop.loop(); 12354280cfSShuo Chen} 13354280cfSShuo Chen 14354280cfSShuo Chenint main() 15354280cfSShuo Chen{ 16354280cfSShuo Chen printf("main(): pid = %d, tid = %d\n", 17354280cfSShuo Chen getpid(), muduo::CurrentThread::tid()); 18354280cfSShuo Chen 19354280cfSShuo Chen muduo::EventLoop loop; 20354280cfSShuo Chen 21354280cfSShuo Chen muduo::Thread thread(threadFunc); 22354280cfSShuo Chen thread.start(); 23354280cfSShuo Chen 24354280cfSShuo Chen loop.loop(); 25354280cfSShuo Chen pthread_exit(NULL); 26354280cfSShuo Chen} 27