Inspired by Actix
Basics
- Can deliver messages between actors using receivers (usually a queue implementations)
- Messages distincts and delivers by TypeId
- Messages delivers in a broadcast fashion to many receivers (Cloned)
- There are different kind of receivers implemented:
- BufferUnordered Receiver (in sync and async version depending by handler)
- Synchronized (also sync and async) if receiving part needs syncronization
- SynchronizeBuffered (also sync and async) here are the implmented handlers definitions:
// Handler is Sync and we can spawn many of concurrent tasks
// Handler is not Sync and we cannot spawn many of concurrent tasks same time (uses synchronization primitives such as Mutex or RwLock)
// Handler is not Sync and handler will process items in batched mode
-
Handler Kinds:
- No Synchronization needed (Handler is
Send
+Sync
)- Not batched operations (implemented)
- sync (spawn_blocking)
- async (spawn)
- Batched
- sync (spawn_blocking)
- async (spawn)
- Not batched operations (implemented)
- Synchronization needed (Handler is
Sync
+!Send
)- Not batched operations (implemented)
- sync (spawn_blocking)
- async (spawn)
- Batched (implemented)
- sync (spawn_blocking)
- async (spawn)
- Not batched operations (implemented)
- Synchronization needed and thread dedicated (Handler is
!Sync
+!Send
)- Not batched operations
- sync (spawn_blocking)
- async (spawn)
- Batched
- sync (spawn_blocking)
- async (spawn)
- Not batched operations
- No Synchronization needed (Handler is
-
Example:
use ;
use async_trait;
;
async