MCPcopy Create free account
hub / github.com/deskflow/deskflow / threadFunc

Method threadFunc

src/lib/mt/Thread.cpp:111–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void *Thread::threadFunc(void *vjob)
112{
113 // get this thread's id for logging
114 IArchMultithread::ThreadID id;
115 {
116 ArchThread thread = ARCH->newCurrentThread();
117 id = ARCH->getIDOfThread(thread);
118 ARCH->closeThread(thread);
119 }
120
121 // get job
122 auto *job = static_cast<IJob *>(vjob);
123
124 // run job
125 void *result = nullptr;
126 try {
127 // go
128 LOG_DEBUG1("thread 0x%08x entry", id);
129 job->run();
130 LOG_DEBUG1("thread 0x%08x exit", id);
131 } catch (ThreadCancelException &) {
132 // client called cancel()
133 LOG_DEBUG1("caught cancel on thread 0x%08x", id);
134 delete job;
135 throw;
136 } catch (ThreadExitException &e) {
137 // client called exit()
138 result = e.m_result;
139 LOG_DEBUG1("caught exit on thread 0x%08x, result %p", id, result);
140 } catch (BaseException &e) {
141 LOG_ERR("exception on thread 0x%08x: %s", id, e.what());
142 delete job;
143 throw;
144 } catch (std::exception &e) {
145 LOG_ERR("standard exception on thread 0x%08x: %s", id, e.what());
146 delete job;
147 throw;
148 } catch (...) {
149 LOG_ERR("non-exception throw on thread 0x%08x: <unknown>", id);
150 delete job;
151 throw;
152 }
153
154 // done with job
155 delete job;
156
157 // return exit result
158 return result;
159}

Callers

nothing calls this directly

Calls 5

newCurrentThreadMethod · 0.45
getIDOfThreadMethod · 0.45
closeThreadMethod · 0.45
runMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected