3#include "unwrapFuture.h"
5#include <CesiumUtility/Tracing.h>
12template <
typename T>
struct WithTracing {
13 template <
typename Func>
15 begin([[maybe_unused]]
const char* tracingName, [[maybe_unused]] Func&& f) {
16#if CESIUM_TRACING_ENABLED
18 [tracingName, CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](T&& result)
mutable {
19 CESIUM_TRACE_USE_CAPTURED_TRACK();
21 CESIUM_TRACE_BEGIN_IN_TRACK(tracingName);
23 return std::move(result);
26 return CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f));
30 template <
typename Func>
31 static auto end([[maybe_unused]]
const char* tracingName, Func&& f) {
32#if CESIUM_TRACING_ENABLED
34 f = CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f)),
35 CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](T&& result)
mutable {
36 CESIUM_TRACE_USE_CAPTURED_TRACK();
38 CESIUM_TRACE_END_IN_TRACK(tracingName);
40 return f(std::move(result));
43 return CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f));
48template <
typename T>
struct WithTracingShared {
49 template <
typename Func>
51 begin([[maybe_unused]]
const char* tracingName, [[maybe_unused]] Func&& f) {
52#if CESIUM_TRACING_ENABLED
54 CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](
const T& result)
mutable {
55 CESIUM_TRACE_USE_CAPTURED_TRACK();
57 CESIUM_TRACE_BEGIN_IN_TRACK(tracingName);
62 return CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
66 template <
typename Func>
67 static auto end([[maybe_unused]]
const char* tracingName, Func&& f) {
68#if CESIUM_TRACING_ENABLED
70 f = CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f)),
71 CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](
const T& result)
mutable {
72 CESIUM_TRACE_USE_CAPTURED_TRACK();
74 CESIUM_TRACE_END_IN_TRACK(tracingName);
79 return CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
84template <>
struct WithTracing<void> {
85 template <
typename Func>
87 begin([[maybe_unused]]
const char* tracingName, [[maybe_unused]] Func&& f) {
88#if CESIUM_TRACING_ENABLED
89 return [tracingName, CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()]()
mutable {
90 CESIUM_TRACE_USE_CAPTURED_TRACK();
92 CESIUM_TRACE_END_IN_TRACK(tracingName);
96 return CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f));
100 template <
typename Func>
101 static auto end([[maybe_unused]]
const char* tracingName, Func&& f) {
102#if CESIUM_TRACING_ENABLED
104 f = CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f)),
105 CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()]()
mutable {
106 CESIUM_TRACE_USE_CAPTURED_TRACK();
108 CESIUM_TRACE_END_IN_TRACK(tracingName);
113 return CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f));
119template <>
struct WithTracingShared<void> :
public WithTracing<void> {};
Classes that support asynchronous operations.