4 ms·
I’ve been toying with these lately, too. My solution was to give each actor an executor where it will run: actor<int> foo(stlab::default_executor, “name”,
by MontagFTB 4y ago
I’ve been toying with these lately, too. My solution was to give each actor an executor where it will run:
actor<int> foo(stlab::default_executor, “name”, 42);
auto f = foo.send([](auto& x){
std::cout << x << ‘\n’; // prints 42
});
Each call to ‘send’ returns a stlab::future which can have a continuation chained, etc.
The nice thing about these is the executor based interface is generic. The actor could be dedicated to a thread, run on an OS-provided thread pool, etc.
At the time the actor is running, the thread it is on is temporarily given the name of the actor to ease debugging.