Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to wakeup a protocol? #3

Closed
erikjohnston opened this issue Nov 14, 2015 · 6 comments
Closed

How to wakeup a protocol? #3

erikjohnston opened this issue Nov 14, 2015 · 6 comments

Comments

@erikjohnston
Copy link
Contributor

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?

@erikjohnston erikjohnston changed the title How to wakeup a protocol. How to wakeup a protocol? Nov 14, 2015
@tailhook
Copy link
Owner

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.

@erikjohnston
Copy link
Contributor Author

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 😄

Keep up the good work!

@tailhook
Copy link
Owner

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.

@erikjohnston
Copy link
Contributor Author

Wonderful, thanks for the update! I'll try and have a look over the next week, but the preliminary API looks good.

@tailhook
Copy link
Owner

tailhook commented Jan 4, 2016

Just released a version on crates.io. Hopefully add some docs soon.

@tailhook tailhook closed this as completed Jan 4, 2016
@erikjohnston
Copy link
Contributor Author

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
#3 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants