You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Concurrency and async programming do not require a multi-threaded environment. You can run async tasks on a single-threaded executor, which allows you to write async code without the Send bound.
478
+
479
+
This approach has several benefits:
480
+
481
+
- Simpler code: No need for Arc, Mutex(RwLock), or other thread synchronization primitives for shared state.
482
+
483
+
- Ergonomic references: You can freely use references within your async code without worrying about moving data across threads. 🤯
484
+
485
+
- Efficient design: This model aligns with the “Thread-per-Core” pattern, letting you safely run multiple async tasks concurrently on a single thread.
486
+
487
+
In short: you get all the power of async/await without the complexity of multi-threaded synchronization all the time.
488
+
489
+
Just switching to a [LocalExecutor](https://docs.rs/async-executor/latest/async_executor/struct.LocalExecutor.html) or something like Tokio [LocalSet](https://docs.rs/tokio/latest/tokio/task/struct.LocalSet.html) should be enough.
490
+
491
+
If you want to enable single-threaded, Send-free async support, you can enable the optional feature `not-send-futures` when adding fmodel-rust to your project:
492
+
493
+
```toml
494
+
[dependencies]
495
+
fmodel-rust = { version = "0.8.2", features = ["not-send-futures"] }
496
+
```
497
+
498
+
Example of the concurrent execution of the aggregate in single-threaded environment (**behind feature** - `Send` free `Futures`):
0 commit comments