Closed erikjohnston closed 8 years ago
Well, this is something half-baked. You need to know the token, but I don't want to expose token directly. I want some kind of Future object, that can be used to send the messages.
The problem with exposing token is that it is reused very fast in the current Slab implementation. I.e. if you just removed the state machine, you free the token and the next state machine is allocated with this exact token (not the smallest number, but the latest one). So it's hard to use.
So yes the feature is not fully designed yet.
Okay, that's fair enough; I was just wondering if I had missed something. I know this is a work in progress, but I'm quite excited by the project and really want to try hacking some things together to get a feel for it. I'll just have to contain my impatience for now though :smile:
Keep up the good work!
Okay, I've just pushed the "future" branch of "rotor" and "rotor-http". The basic idea is that you do:
let (port, future) = scope.pair()
The port
is a thing used to push value to the future:
port.set(xxx)
This sets the value and wakes up the state machine that created the future initially. Port should be thread safe.
The future
is received. It's expected to be looked at in .wakeup()
handler:
if future.done() {
value = future.get()
}
This is very preliminary API. Also, support of this in rotor-HTTP
is mostly missing. But I'm publishing a branch just because people keep asking. To get things built, you may want to setup cargo config
Any feedback is appreciated.
Wonderful, thanks for the update! I'll try and have a look over the next week, but the preliminary API looks good.
Just released a version on crates.io. Hopefully add some docs soon.
Fab! Thanks :)
On Mon, 4 Jan 2016 11:16 Paul Colomiets notifications@github.com wrote:
Just released a version on crates.io. Hopefully add some docs soon.
— Reply to this email directly or view it on GitHub https://github.com/tailhook/rotor/issues/3#issuecomment-168649540.
Reading the code it appears that to wake a protocol/event machine/thing up I need to know its associated
mio::Token
, however that doesn't seem to be exposed anywhere. Is this possible to do currently?