| 188 | |
| 189 | |
| 190 | void PooledThread::run() |
| 191 | { |
| 192 | DB::ThreadStatus thread_status; |
| 193 | if (unlikely(_globalProfilerRealTimePeriodNs != 0 || _globalProfilerCPUTimePeriodNs != 0)) |
| 194 | thread_status.initGlobalProfiler(_globalProfilerRealTimePeriodNs, _globalProfilerCPUTimePeriodNs); |
| 195 | |
| 196 | _started.set(); |
| 197 | for (;;) |
| 198 | { |
| 199 | _targetReady.wait(); |
| 200 | _mutex.lock(); |
| 201 | if (_pTarget) // a NULL target means kill yourself |
| 202 | { |
| 203 | Runnable* pTarget = _pTarget; |
| 204 | _mutex.unlock(); |
| 205 | try |
| 206 | { |
| 207 | pTarget->run(); |
| 208 | } |
| 209 | catch (Exception& exc) |
| 210 | { |
| 211 | ErrorHandler::handle(exc); |
| 212 | } |
| 213 | catch (std::exception& exc) |
| 214 | { |
| 215 | ErrorHandler::handle(exc); |
| 216 | } |
| 217 | catch (...) |
| 218 | { |
| 219 | ErrorHandler::handle(); |
| 220 | } |
| 221 | FastMutex::ScopedLock lock(_mutex); |
| 222 | _pTarget = 0; |
| 223 | _idleTime = time(NULL); |
| 224 | _idle = true; |
| 225 | _targetCompleted.set(); |
| 226 | ThreadLocalStorage::clear(); |
| 227 | _thread.setName(_name); |
| 228 | _thread.setPriority(Thread::PRIO_NORMAL); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | _mutex.unlock(); |
| 233 | break; |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | |
| 239 | ThreadPool::ThreadPool(int minCapacity, |
nothing calls this directly
no test coverage detected