test1.cc revision cc7f415c
1cc7f415cSShuo Chen#include "EventLoop.h" 2cc7f415cSShuo Chen#include "thread/Thread.h" 3cc7f415cSShuo Chen#include <stdio.h> 4cc7f415cSShuo Chen 5cc7f415cSShuo Chenvoid threadFunc() 6cc7f415cSShuo Chen{ 7cc7f415cSShuo Chen printf("threadFunc(): pid = %d, tid = %d\n", getpid(), muduo::CurrentThread::tid()); 8cc7f415cSShuo Chen 9cc7f415cSShuo Chen muduo::EventLoop loop; 10cc7f415cSShuo Chen loop.loop(); 11cc7f415cSShuo Chen} 12cc7f415cSShuo Chen 13cc7f415cSShuo Chenint main() 14cc7f415cSShuo Chen{ 15cc7f415cSShuo Chen printf("main(): pid = %d, tid = %d\n", getpid(), muduo::CurrentThread::tid()); 16cc7f415cSShuo Chen 17cc7f415cSShuo Chen muduo::EventLoop loop; 18cc7f415cSShuo Chen 19cc7f415cSShuo Chen muduo::Thread thread(threadFunc); 20cc7f415cSShuo Chen thread.start(); 21cc7f415cSShuo Chen 22cc7f415cSShuo Chen loop.loop(); 23cc7f415cSShuo Chen pthread_exit(NULL); 24cc7f415cSShuo Chen} 25