| 17 | |
| 18 | template<typename Predicate, typename Body> |
| 19 | __forceinline void TaskScheduler::steal_loop(Thread& thread, const Predicate& pred, const Body& body) |
| 20 | { |
| 21 | while (true) |
| 22 | { |
| 23 | /*! some rounds that yield */ |
| 24 | for (size_t i=0; i<32; i++) |
| 25 | { |
| 26 | /*! some spinning rounds */ |
| 27 | const size_t threadCount = thread.threadCount(); |
| 28 | for (size_t j=0; j<1024; j+=threadCount) |
| 29 | { |
| 30 | if (!pred()) return; |
| 31 | if (thread.scheduler->steal_from_other_threads(thread)) { |
| 32 | i=j=0; |
| 33 | body(); |
| 34 | } |
| 35 | } |
| 36 | yield(); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /*! run this task */ |
| 42 | void TaskScheduler::Task::run_internal (Thread& thread) // FIXME: avoid as many dll_exports as possible |
nothing calls this directly
no test coverage detected