16using std::execution::par;
17using std::execution::par_unseq;
18using std::execution::seq;
20#ifdef MAYAFLUX_PLATFORM_MACOS
31template <
typename Func,
typename... Args>
34 dispatch_async(dispatch_get_main_queue(), ^{
35 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
50template <
typename Func,
typename... Args>
53 using ResultType = std::invoke_result_t<Func, Args...>;
55 if constexpr (std::is_void_v<ResultType>) {
56 dispatch_sync(dispatch_get_main_queue(), ^{
57 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
60 __block ResultType result;
61 dispatch_sync(dispatch_get_main_queue(), ^{
62 result = std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
80template <
typename Func,
typename... Args>
83 auto completed = std::make_shared<std::atomic<bool>>(
false);
85 dispatch_async(dispatch_get_main_queue(), ^{
86 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
87 completed->store(
true, std::memory_order_release);
90 auto start = std::chrono::steady_clock::now();
91 while (!completed->load(std::memory_order_acquire)) {
92 if (std::chrono::steady_clock::now() - start > timeout_ms) {
95 std::this_thread::sleep_for(std::chrono::milliseconds(1));
103template <
typename Func,
typename... Args>
106 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
109template <
typename Func,
typename... Args>
112 return std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
115template <
typename Func,
typename... Args>
118 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);