| 102 | }; |
| 103 | |
| 104 | int main() |
| 105 | { |
| 106 | std::unique_ptr<Printer> printer; // make sure printer lives longer than loops, to avoid |
| 107 | // race condition of calling print2() on destructed object. |
| 108 | muduo::net::EventLoop loop; |
| 109 | muduo::net::EventLoopThread loopThread; |
| 110 | muduo::net::EventLoop* loopInAnotherThread = loopThread.startLoop(); |
| 111 | printer.reset(new Printer(&loop, loopInAnotherThread)); |
| 112 | loop.loop(); |
| 113 | } |
| 114 |