SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
|
Static utility class for executing CPU-intensive tasks asynchronously. More...
#include <CpuTaskExecutor.h>
Static Public Member Functions | |
template<typename Func > | |
static auto | executeAsync (std::shared_ptr< SLLooper > resultLooper, Func &&func) -> Promise< decltype(func())> |
Execute CPU-bound task asynchronously without timeout. | |
template<typename Func > | |
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. | |
Static utility class for executing CPU-intensive tasks asynchronously.
CpuTaskExecutor provides a high-level interface for executing CPU-bound tasks in separate threads while integrating seamlessly with the event loop pattern. Key features include:
Architecture:
Use cases:
Definition at line 128 of file CpuTaskExecutor.h.
|
static |
Execute CPU-bound task asynchronously without timeout.
Func | Function type (auto-deduced) |
resultLooper | SLLooper instance for result callback execution |
func | CPU-intensive function to execute |
Executes CPU-intensive tasks in a separate thread without timeout limits. This is the preferred method for tasks with predictable execution times or when timeout protection is handled at a higher level.
Key characteristics:
Execution flow:
|
static |
Execute CPU-bound task asynchronously with timeout protection.
Func | Function type (auto-deduced) |
resultLooper | SLLooper instance for result callback execution |
func | CPU-intensive function to execute |
timeout | Maximum execution time before timeout exception |
Executes CPU-intensive tasks with timeout protection to prevent runaway computations from hanging the application. Uses a two-level async approach for precise timeout detection while maintaining the same Promise-based result delivery mechanism.
Key characteristics:
Timeout behavior: