This would work similarly to until, but rather than yielding on the current thread, we would instead spin up a sub-thread to wait + perform an action.
API usage would look something like:
on<EventType>
(
[](auto&& event_instance)
{
print("Event received, doing work on sub-thread.");
// ...
}
);
on
(
// Predicate:
[]() -> bool
{
return (condition_to_be_met); // Ran on a sub-thread.
},
// Work:
[](auto& self)
{
print("Doing work on new sub-thread");
// ...
}
)
// NOTE: `on<EventType>(event_predicate_here, some_work_here)` should also work.
This would make sub-threads a lot simpler to use in one-off cases. -- e.g. when waiting for an input that can change or cancel a state.
This would work similarly to
until
, but rather than yielding on the current thread, we would instead spin up a sub-thread to wait + perform an action.API usage would look something like:
This would make sub-threads a lot simpler to use in one-off cases. -- e.g. when waiting for an input that can change or cancel a state.