| 40 | streamfx::util::threadpool::task::~task() {} |
| 41 | |
| 42 | void streamfx::util::threadpool::task::run() |
| 43 | { |
| 44 | std::lock_guard<std::mutex> lg(_lock); |
| 45 | if (!_cancelled) { |
| 46 | try { |
| 47 | _callback(_data); |
| 48 | } catch (const std::exception& ex) { |
| 49 | D_LOG_ERROR("Unhandled exception in Task: %s.", ex.what()); |
| 50 | _failed = false; |
| 51 | } catch (...) { |
| 52 | D_LOG_ERROR("Unhandled exception in Task.", nullptr); |
| 53 | _failed = true; |
| 54 | } |
| 55 | } |
| 56 | _completed = true; |
| 57 | _status_changed.notify_all(); |
| 58 | } |
| 59 | |
| 60 | void streamfx::util::threadpool::task::cancel() |
| 61 | { |