News for hackers. Stuff that matters.
Re:Making the Tokio scheduler 10x faster by carllerche on Monday October 14, 2019 @01:36PM (#21250729)
> So the question here is why not to expose generic state machine framework (FSM/HSM) which can deal with those protocols but is also very useful for many other tasks as well?

Short answer is: you can.

Tokio is more like "node.js for Rust" or "the Go runtime for Rust".

The bit about Tokio & futures is how you use Tokio today. Tasks are defined as futures, and Rust futures are FSMs. So, a protocol can be implemented as a FSM completely independently of Tokio / futures and then used from Tokio.

In Tokio's next major release (coming soon), it will work with Rust's async fn feature (which is also about to hit stable).

Hope that clarifies things.

Re:Making the Tokio scheduler 10x faster by FpUser on Monday October 14, 2019 @01:51PM (#21250904)
So, a protocol can be implemented as a FSM completely independently of Tokio / futures and then used from Tokio

But that was the point of my question. Since you've already built that FSM framework inside, why not to expose it? Or I guess it might be too specialized for your particular case.

Re:Making the Tokio scheduler 10x faster by carllerche on Monday October 14, 2019 @01:59PM (#21250980)
Ah, all the helpers around the "FSM" aspect of things are already exposed as part of the `futures` crate: https://github.com/rust-lang-nursery/futures-rs/
Re:Making the Tokio scheduler 10x faster by MuffinFlavored on Monday October 14, 2019 @07:34PM (#21254028)
Which is different than the standard adopted `std::futures`?
Re:Making the Tokio scheduler 10x faster by steveklabnik on Monday October 14, 2019 @08:44PM (#21254464)
No; it re-exports the standard futures. Its purpose is two-fold: one, it's where futures were experimented with before they got into std, and two, it's where extra functionality can live. We only put what was absolutely necessary into std.
Re:Making the Tokio scheduler 10x faster by shepmaster on Monday October 14, 2019 @08:42PM (#21254456)
Not quite. The futures crate, version 0.1, contained a definition of the `Future` trait and a bunch of the combinator methods. This was iterated on a lot. Eventually, the bare minimum traits were added to the standard library.

The futures crate, version 0.3 (released under the name `futures-preview` right now with an alpha version number), contains the helper methods for the standard library's trait.

Re:Making the Tokio scheduler 10x faster by autumnal on Tuesday October 15, 2019 @08:01AM (#21257569)
Just the bare minimum traits required for built-in async/.await, right?
Re:Making the Tokio scheduler 10x faster by GolDDranks on Monday October 14, 2019 @02:25PM (#21251240)
A major part of the FSM generation is a language feature in Rust, (async/await), not a feature of Tokio. (I'm assuming we are speaking about the incoming version 0.2 here.) Tokio just leverages it. On the other hand, Tokio and the surrounding ecosystem have built all kinds of helpers around that, mentioned in the sister comment.
Re:Making the Tokio scheduler 10x faster by woah on Monday October 14, 2019 @01:58PM (#21250978)
My guess is that they don't want to have to maintain a separate stable public API for what is currently some internal mechanics. Maybe in a few years when the FSM is more or less set in stone, someone will expose it.