Thomasdezeeuw / heph

Heph is an actor library for Rust based on asynchronous functions.
MIT License
129 stars 6 forks source link

Rework synchronous actors in heph #590

Closed Thomasdezeeuw closed 1 year ago

Thomasdezeeuw commented 1 year ago

Create a new heph::sync module, which contains all the types related to sync actors, such as SyncActor and SyncContext. Within that module I've added SyncActorRunner (previously called SyncWorker and private) and SyncActorRunnerBuilder (yes, it's too long), which can be use to run synchronous actors, catching errors, etc.

This also adds panic handling within the SyncActorRunner, which required the SyncSupervisor::decide_on_panic method. Which is similar to Supervisor::decide_on_panic for async actors.

Finally I've added SyncActor::name to determine the name of the sync actor. With ActorFn this actually produces are reasonable result, with sync_actor as fn(..) -> _ not so much.

Closes #572 Closes #576