Skip to content

Select on newrt pipes #8008

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

Merged
merged 8 commits into from
Jul 31, 2013
Merged

Select on newrt pipes #8008

merged 8 commits into from
Jul 31, 2013

Conversation

bblum
Copy link
Contributor

@bblum bblum commented Jul 23, 2013

Main logic in Implement select() for new runtime pipes.. The guts of the PortOne::try_recv() implementation are now split up across several functions, optimistic_check, block_on, and recv_ready.

There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with SharedPort. Still investigating this.

@brson
Copy link
Contributor

brson commented Jul 29, 2013

I still haven't fully digested this, but here are a couple of observations:

The commented out assertions in the comm code is worrying.

It looks like all of rt::select is intended to be a public API, so will eventually more likely live at std::select. Nothing in the API is tied to pipes, which is good, but Select itself exposes both Scheduler and BlockedTask, and both of these types are runtime implementation details and should not be part of the public interface. What are our options for hiding these types from the select API?

@bblum
Copy link
Contributor Author

bblum commented Jul 29, 2013

Oh yeah, the trait. Probably the thing to do is to have rt::select, which exports the trait as a non-pub module to only the rest of libstd, and have std::select which exports the select function.

@brson
Copy link
Contributor

brson commented Jul 30, 2013

I still don't see how to encapsulate this into a public select api that doesn't expose runtime internals, at least one that is generic over multiple types of selectable things.

@bblum
Copy link
Contributor Author

bblum commented Jul 31, 2013

If I am not mistaken, as long as the trait Select and trait SelectPort<T> are not themselves pub, then they won't expose runtime internals, but users will still be able to take advantage of the typeclass when calling select functions.

If I am mistaken, we can at least do something like:

trait SelectInner { ... runtime internals ... }
pub trait Select : SelectInner { }
trait SelecPortInner<T> { ... runtime internals ... }
pub trait SelectPort<T> : SelectPortInner<T> { }

@brson
Copy link
Contributor

brson commented Jul 31, 2013

Regarding the suggestion of how to hide the runtime internals, I'm not comfortable with the idea of mentioning types that aren't public in the signature of other public items (and kind of think that it's a wart that Rust allows it at all). This isn't a pattern we use anywhere else, and would need some wider discussion to determine if that's ok.

bors added a commit that referenced this pull request Jul 31, 2013
Main logic in ```Implement select() for new runtime pipes.```. The guts of the ```PortOne::try_recv()``` implementation are now split up across several functions, ```optimistic_check```, ```block_on```, and ```recv_ready```.

There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with ```SharedPort```. Still investigating this.
@glaebhoerl
Copy link
Contributor

Wouldn't it be enough for the traits' methods to be private, and not the traits themselves?

@bors bors closed this Jul 31, 2013
@bors bors merged commit 6b75e92 into rust-lang:master Jul 31, 2013
@bblum
Copy link
Contributor Author

bblum commented Jul 31, 2013

True, I can't really imagine it would look very friendly in the documentation, either. Seems like the SelectInner thing is the way to go.

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

Successfully merging this pull request may close these issues.

4 participants