34 template <
class Function>
35 requires std::invocable<Function&, std::size_t>
38 using function_type = std::remove_reference_t<Function>;
40 size,
const_cast<void*
>(
static_cast<void const*
>(std::addressof(function))),
41 [](
void* context, std::size_t index) { std::invoke(*
static_cast<function_type*
>(context), index); }};
45 [[nodiscard]]
auto size() const noexcept ->
std::
size_t {
return size_; }
49 void operator()(std::size_t index)
const { invoke_(context_, index); }
52 using invoke_type = void (*)(
void*, std::size_t);
55 : size_(
size), context_(context), invoke_(invoke)
76 virtual bool accepts_route(
TaskRoute route)
const noexcept = 0;
85 virtual void reschedule(
BasicTask&& task) = 0;
111 template <
class Function>
112 requires std::invocable<Function&, std::size_t>
116 this->execute_batch_impl(batch);
156 std::this_thread::yield();
188 for (std::size_t index = 0; index < batch.
size(); ++index)
Promise-neutral coroutine task ownership and the public AsyncTask type.
Canonical host-oriented coroutine task type.
Definition async_task.hpp:196
Move-only promise-neutral ownership claim for a Uni20 coroutine.
Definition async_task.hpp:103
Scheduler interface for initial AsyncTask submission and host-side progress.
Definition scheduler.hpp:89
virtual void pause()=0
Pause the scheduler.
virtual void help_while_waiting(const WaitPredicate &is_ready)
Allow a scheduler to advance queued work while a thread is blocking.
Definition scheduler.hpp:152
std::function< void(WaitWakeup)> WaitWakeupRegistration
Definition scheduler.hpp:129
std::function< void()> WaitWakeup
Definition scheduler.hpp:128
std::function< bool()> WaitPredicate
Definition scheduler.hpp:127
~IAsyncScheduler() override=default
Virtual destructor.
virtual void schedule(AsyncTask &&task)=0
Schedule a coroutine for its initial execution.
virtual void wait_for(WaitRequest const &request)
Block until a structured wait request becomes ready.
Definition scheduler.hpp:181
virtual void wait_for(const WaitPredicate &is_ready)
Block the calling thread until is_ready returns true.
Definition scheduler.hpp:166
virtual void resume()=0
Resume the scheduler.
void execute_batch(std::size_t size, Function &&function)
Execute a synchronous batch of independent lightweight work items.
Definition scheduler.hpp:113
Internal route for resuming an already-bound coroutine task.
Definition scheduler.hpp:64
virtual ~IScheduler()=default
Virtual destructor.
Borrowed type-erased description of a synchronous lightweight task batch.
Definition scheduler.hpp:28
void operator()(std::size_t index) const
Execute one work item.
Definition scheduler.hpp:49
auto size() const noexcept -> std::size_t
Return the number of independent work items.
Definition scheduler.hpp:45
static auto bind(std::size_t size, Function &function) -> LightweightTaskBatch
Bind a callable for the duration of one synchronous batch call.
Definition scheduler.hpp:36
Non-owning erased identity for one Uni20 coroutine frame.
Definition async_task.hpp:59
Shared non-polymorphic implementation for Uni20 task promises.
Definition async_task_promise.hpp:99
This represents the reverse-mode adjoint for functions of complex variables, assuming a real-valued s...
Definition async/async.hpp:26
Readiness predicate and optional targeted wakeup registration for a blocking wait.
Definition scheduler.hpp:133
WaitPredicate is_ready
Predicate that reports whether the requested value is available.
Definition scheduler.hpp:135
WaitWakeupRegistration notify_when_ready
Register a non-throwing wakeup, including when readiness races with registration.
Definition scheduler.hpp:142
Execution requirements used to validate a scheduler route.
Definition async_task.hpp:43