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

Method print1

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

Source from the content-addressed store, hash-verified

28 }
29
30 void print1()
31 {
32 bool shouldQuit = false;
33 int count = 0;
34
35 {
36 muduo::MutexLockGuard lock(mutex_);
37 if (count_ < 10)
38 {
39 count = count_;
40 ++count_;
41 }
42 else
43 {
44 shouldQuit = true;
45 }
46 }
47
48 // out of lock
49 if (shouldQuit)
50 {
51 // printf("loop1_->quit()\n");
52 loop1_->quit();
53 }
54 else
55 {
56 // cout is not thread safe
57 //std::cout << "Timer 1: " << count << "\n";
58 printf("Timer 1: %d\n", count);
59 loop1_->runAfter(1, std::bind(&Printer::print1, this));
60 }
61 }
62
63 void print2()
64 {

Callers

nothing calls this directly

Calls 2

runAfterMethod · 0.80
quitMethod · 0.45

Tested by

no test coverage detected