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

Method runInThread

muduo/base/Thread.cc:70–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 { }
69
70 void runInThread()
71 {
72 *tid_ = muduo::CurrentThread::tid();
73 tid_ = NULL;
74 latch_->countDown();
75 latch_ = NULL;
76
77 muduo::CurrentThread::t_threadName = name_.empty() ? "muduoThread" : name_.c_str();
78 ::prctl(PR_SET_NAME, muduo::CurrentThread::t_threadName);
79 try
80 {
81 func_();
82 muduo::CurrentThread::t_threadName = "finished";
83 }
84 catch (const Exception& ex)
85 {
86 muduo::CurrentThread::t_threadName = "crashed";
87 fprintf(stderr, "exception caught in Thread %s\n", name_.c_str());
88 fprintf(stderr, "reason: %s\n", ex.what());
89 fprintf(stderr, "stack trace: %s\n", ex.stackTrace());
90 abort();
91 }
92 catch (const std::exception& ex)
93 {
94 muduo::CurrentThread::t_threadName = "crashed";
95 fprintf(stderr, "exception caught in Thread %s\n", name_.c_str());
96 fprintf(stderr, "reason: %s\n", ex.what());
97 abort();
98 }
99 catch (...)
100 {
101 muduo::CurrentThread::t_threadName = "crashed";
102 fprintf(stderr, "unknown exception caught in Thread %s\n", name_.c_str());
103 throw; // rethrow
104 }
105 }
106};
107
108void* startThread(void* obj)

Callers 1

startThreadFunction · 0.45

Calls 6

tidFunction · 0.85
countDownMethod · 0.80
c_strMethod · 0.80
whatMethod · 0.80
stackTraceMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected