commonwarexyz / monorepo

Commonware Library Primitives and Examples
https://commonware.xyz/
Apache License 2.0
49 stars 7 forks source link

[runtime] Add `thread` dialect #98

Open patrick-ogrady opened 1 month ago

patrick-ogrady commented 1 month ago

Wait to start until https://github.com/commonwarexyz/monorepo/pull/102 is merged.

Write a runtime dialect that spawns kernel threads: https://doc.rust-lang.org/book/ch16-01-threads.html

Some developers prefer to spawn dedicated threads for each subcomponent of their application. Right now, the only production option in runtime is to use Tokio's tasks (which have very different behavior): https://docs.rs/tokio/latest/tokio/task/

patrick-ogrady commented 1 month ago

It may be better to incorporate this into runtime::tokio by modifying the spawn interface to have "priority"? This would allow a nice mix and match in something like p2p::authenticated where the core handlers could be threads and the peer handlers could be tokio tasks.