3 #include "cesium-async++.h"
5 #include <CesiumUtility/Assert.h>
7 #include <spdlog/spdlog.h>
10 namespace CesiumImpl {
15 : _pScheduler(pScheduler) {}
17 void schedule(async::task_run_handle t) {
19 std::vector<TScheduler*>& inSuitable =
21 if (std::find(inSuitable.begin(), inSuitable.end(), this->_pScheduler) !=
27 this->_pScheduler->schedule(std::move(t));
33 SchedulerScope(TScheduler* pScheduler =
nullptr) : _pScheduler(pScheduler) {
34 if (this->_pScheduler) {
35 std::vector<TScheduler*>& inSuitable =
37 inSuitable.push_back(this->_pScheduler);
44 : _pScheduler(rhs._pScheduler) {
45 rhs._pScheduler =
nullptr;
49 std::swap(this->_pScheduler, rhs._pScheduler);
53 void reset() noexcept {
54 if (this->_pScheduler) {
55 std::vector<TScheduler*>& inSuitable =
57 CESIUM_ASSERT(!inSuitable.empty());
58 CESIUM_ASSERT(inSuitable.back() == this->_pScheduler);
59 inSuitable.pop_back();
61 this->_pScheduler =
nullptr;
69 TScheduler* _pScheduler;
75 TScheduler* _pScheduler;
80 static std::vector<TScheduler*>&
81 getSchedulersCurrentlyDispatching() noexcept {
87 static thread_local std::vector<TScheduler*> schedulersCurrentlyDispatching;
88 return schedulersCurrentlyDispatching;
Classes that support asynchronous operations.