51 template <
typename Func>
53 return this->thenWithScheduler(
54 this->_pSchedulers->workerThread.immediate,
55 "waiting for worker thread",
56 std::forward<Func>(f));
77 template <
typename Func>
79 return this->thenWithScheduler(
80 this->_pSchedulers->mainThread.immediate,
81 "waiting for main thread",
82 std::forward<Func>(f));
100 template <
typename Func>
102 return CesiumImpl::ContinuationFutureType_t<Func, T>(
105 async::inline_scheduler(),
106 CesiumImpl::WithTracingShared<T>::end(
108 std::forward<Func>(f))));
130 template <
typename Func>
131 CesiumImpl::ContinuationFutureType_t<Func, T>
133 return this->thenWithScheduler(
134 threadPool._pScheduler->immediate,
135 "waiting for thread pool thread",
136 std::forward<Func>(f));
161 return this->catchWithScheduler(
162 this->_pSchedulers->mainThread.immediate,
163 std::forward<Func>(f));
186 return this->catchWithScheduler(
187 async::inline_scheduler(),
188 std::forward<Func>(f));
203 template <
typename... TPassThrough>
204 Future<std::tuple<TPassThrough..., T>>
207 [values = std::tuple(std::forward<TPassThrough>(values)...)](
208 const T& result)
mutable {
209 return std::tuple_cat(std::move(values), std::make_tuple(result));
228 std::enable_if_t<std::is_same_v<U, T>,
int> = 0,
229 std::enable_if_t<!std::is_same_v<U, void>,
int> = 0>
231 return this->_task.get();
248 std::enable_if_t<std::is_same_v<U, T>,
int> = 0,
249 std::enable_if_t<std::is_same_v<U, void>,
int> = 0>
269 return this->_pSchedulers->mainThread.dispatchUntilTaskCompletes(
270 std::move(this->_task));
283 bool isReady()
const {
return this->_task.ready(); }
287 const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
288 async::shared_task<T>&& task) noexcept
289 : _pSchedulers(pSchedulers), _task(std::move(task)) {}
291 template <
typename Func,
typename Scheduler>
292 CesiumImpl::ContinuationFutureType_t<Func, T>
293 thenWithScheduler(Scheduler& scheduler,
const char* tracingName, Func&& f) {
298#if CESIUM_TRACING_ENABLED
301 auto task = this->_task.then(
302 async::inline_scheduler(),
303 CesiumImpl::WithTracingShared<T>::begin(
305 std::forward<Func>(f)));
307 auto& task = this->_task;
310 return CesiumImpl::ContinuationFutureType_t<Func, T>(
314 CesiumImpl::WithTracingShared<T>::end(
316 std::forward<Func>(f))));
319 template <
typename Func,
typename Scheduler>
320 CesiumImpl::ContinuationFutureType_t<Func, std::exception>
321 catchWithScheduler(Scheduler& scheduler, Func&& f) {
322 return CesiumImpl::ContinuationFutureType_t<Func, std::exception>(
325 async::inline_scheduler(),
327 CatchFunction<Func, T, Scheduler,
const async::shared_task<T>&>{
329 std::forward<Func>(f)}));
332 std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
333 async::shared_task<T> _task;
335 friend class AsyncSystem;
337 template <
typename R>
friend struct CesiumImpl::ParameterizedTaskUnwrapper;
339 friend struct CesiumImpl::TaskUnwrapper;
341 template <
typename R>
friend class Future;
342 template <
typename R>
friend class SharedFuture;