| 27 | } |
| 28 | |
| 29 | void scheduler_t::bind() |
| 30 | { |
| 31 | SKR_ASSERT(scheduler == nullptr); |
| 32 | SKR_ASSERT(internal == nullptr); |
| 33 | internal = new ftl::TaskScheduler(); |
| 34 | options.Callbacks.Context = this; |
| 35 | options.Callbacks.OnWorkerThreadStarted = [](void* context, unsigned threadIndex) |
| 36 | { |
| 37 | scheduler = (scheduler_t*)context; |
| 38 | ftl::BindScheduler(scheduler->internal); |
| 39 | }; |
| 40 | options.Callbacks.OnWorkerThreadEnded = [](void* context, unsigned threadIndex) |
| 41 | { |
| 42 | scheduler = nullptr; |
| 43 | ftl::UnbindScheduler(); |
| 44 | }; |
| 45 | internal->Init(options); |
| 46 | scheduler = this; |
| 47 | ftl::BindScheduler(internal); |
| 48 | } |
| 49 | void scheduler_t::unbind() |
| 50 | { |
| 51 | SKR_ASSERT(internal); |