MCPcopy Create free account
hub / github.com/chenshuo/muduo / print2

Method print2

examples/asio/tutorial/timer6/timer.cc:63–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 void print2()
64 {
65 bool shouldQuit = false;
66 int count = 0;
67
68 {
69 muduo::MutexLockGuard lock(mutex_);
70 if (count_ < 10)
71 {
72 count = count_;
73 ++count_;
74 }
75 else
76 {
77 shouldQuit = true;
78 }
79 }
80
81 // out of lock
82 if (shouldQuit)
83 {
84 // printf("loop2_->quit()\n");
85 loop2_->quit();
86 }
87 else
88 {
89 // cout is not thread safe
90 //std::cout << "Timer 2: " << count << "\n";
91 printf("Timer 2: %d\n", count);
92 loop2_->runAfter(1, std::bind(&Printer::print2, this));
93 }
94 }
95
96private:
97

Callers

nothing calls this directly

Calls 2

runAfterMethod · 0.80
quitMethod · 0.45

Tested by

no test coverage detected