SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
Loading...
Searching...
No Matches
CpuTaskExecutor.h
Go to the documentation of this file.
1
9 #pragma once
10
11 #include <future>
12 #include <chrono>
13 #include <functional>
14 #include <stdexcept>
15 #include <type_traits>
16
17 // Forward declarations only
18 namespace swt {
19 class SLLooper;
20 template<typename T> class Promise;
21 }
22
23 namespace swt {
24
55 class CpuTaskTimeoutException : public std::runtime_error {
56 public:
69 explicit CpuTaskTimeoutException(const std::string& message)
70 : std::runtime_error(message) {}
71 };
72
129 public:
181 template<typename Func>
182 static auto executeAsync(std::shared_ptr<SLLooper> resultLooper,
183 Func&& func)
184 -> Promise<decltype(func())>;
185
244 template<typename Func>
245 static auto executeAsync(std::shared_ptr<SLLooper> resultLooper,
246 Func&& func,
247 std::chrono::milliseconds timeout)
248 -> Promise<decltype(func())>;
249
250 private:
257 CpuTaskExecutor() = delete;
258
262 CpuTaskExecutor(const CpuTaskExecutor&) = delete;
263
267 CpuTaskExecutor& operator=(const CpuTaskExecutor&) = delete;
268 };
269
270 } // namespace swt
271
272 // Include template implementations
273 #include "CpuTaskExecutor.tpp"
Static utility class for executing CPU-intensive tasks asynchronously.
static auto executeAsync(std::shared_ptr< SLLooper > resultLooper, Func &&func) -> Promise< decltype(func())>
Execute CPU-bound task asynchronously without timeout.
static auto executeAsync(std::shared_ptr< SLLooper > resultLooper, Func &&func, std::chrono::milliseconds timeout) -> Promise< decltype(func())>
Execute CPU-bound task asynchronously with timeout protection.
Exception thrown when CPU-bound tasks exceed timeout limits.
CpuTaskTimeoutException(const std::string &message)
Constructor with timeout message.
Type-safe promise for asynchronous result handling with continuation chaining.
Definition Promise.h:68
Software Timer namespace containing all timer-related classes.
Definition Awaitable.h:21