Open
Description
The run
member function of run_loop
consumes the current thread until the run loop finishes. There should be a way to tell the run_loop
to delegate execution to a separate event loop, like a system event loop.
I can imagine users calling run_loop::run
with an optional callable, which run
will call periodically; maybe after every item that run
processes.
void run_loop::run( callable auto fn ) {
while( auto item = pop_front() ) {
item.execute();
if( !fn( [this]() -> bool { return !this->_is_empty(); } ) )
break;
}
}
}
run
invokes the callable with a predicate that indicates whether the run loop's queue is empty or not. We can use this to drive two run_loop
s on the same thread:
run_loop loop1, loop2;
loop1.run(
[&](auto has_work) {
// Run loop2 while loop1 is empty
loop2.run( [&](auto) { return has_work(); } );
}
);
Metadata
Metadata
Labels
Type
Projects
Status
Ready