| 64 | int pri; |
| 65 | |
| 66 | struct ActionWrapper { |
| 67 | PThreadAction action; |
| 68 | ActionWrapper(PThreadAction action) : action(action) {} |
| 69 | // HACK: Boost won't use move constructors, so we just assume the last copy made is the one that will be called |
| 70 | // or cancelled |
| 71 | ActionWrapper(ActionWrapper const& r) : action(r.action) { const_cast<ActionWrapper&>(r).action = nullptr; } |
| 72 | void operator()() { |
| 73 | Thread::dispatch(action); |
| 74 | action = nullptr; |
| 75 | } |
| 76 | ~ActionWrapper() { |
| 77 | if (action) { |
| 78 | action->cancel(); |
| 79 | } |
| 80 | } |
| 81 | ActionWrapper& operator=(ActionWrapper const&) = delete; |
| 82 | }; |
| 83 | |
| 84 | public: |
| 85 | ThreadPool(int stackSize, int pri) : dontstop(ios), mode(Run), stackSize(stackSize), pri(pri) {} |