| 29 | } |
| 30 | |
| 31 | std::future<void> ThreadPerTaskScheduler::scheduleAndStart(std::packaged_task<void()>&& task) |
| 32 | { |
| 33 | auto result = task.get_future(); |
| 34 | |
| 35 | m_threads.emplace_back([this, task{ move(task) }] () mutable |
| 36 | { |
| 37 | while(m_started) |
| 38 | { |
| 39 | try |
| 40 | { |
| 41 | task(); |
| 42 | } |
| 43 | catch (...) |
| 44 | { |
| 45 | } |
| 46 | } |
| 47 | }); |
| 48 | |
| 49 | return result; |
| 50 | } |
| 51 | |
| 52 | } // namespace Disruptor |