| 109 | } |
| 110 | |
| 111 | void *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 | } |
nothing calls this directly
no test coverage detected