template<size_t TaskSize = 64>
class threadschedule::detail::SboCallable< TaskSize >
Type-erased, move-only callable with configurable inline storage.
Designed as a lightweight replacement for std::function when heap allocations are undesirable. Callables whose size and alignment fit within the inline buffer are stored in-place (Small Buffer Optimization); larger callables fall back to a heap allocation transparently.
- Storage layout
|<---------- TaskSize bytes ---------->|
[ VTable* (8 B) | inline buffer ]
The usable inline buffer is TaskSize - sizeof(void*) bytes (56 bytes on 64-bit platforms with the default TaskSize of 64).
- Inline eligibility
- A callable
F is stored inline when all of the following hold:
sizeof(F) <= kBufferSize
alignof(F) <= alignof(std::max_align_t)
std::is_nothrow_move_constructible_v<F>
- Move semantics
- Move-only. Invoking
operator() consumes the callable (invoke + destroy), leaving the object in an empty state. This single-shot design avoids the overhead of reference counting or shared ownership.
- Thread safety
- Not thread-safe. Intended to be used as a queue element inside a mutex-protected task queue.
- Template Parameters
-
| TaskSize | Total object size in bytes (default 64, one x86 cache line). |
Definition at line 178 of file thread_pool.hpp.