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

Generalized pipes, sendable managed types, simple IPC #4039

Closed
wants to merge 2 commits into from

Conversation

brson
Copy link
Contributor

@brson brson commented Nov 26, 2012

r? @pcwalton

This is a module called flatpipes, which provides a generic pipe for transporting values that can be converted to bytes.

It can do several cool things:

  • Send all serializable types, including managed types
  • Efficiently send POD types
  • Send and receive over I/O streams, including stdio and uv network connections
  • Send and receive managed types over Rust pipes via serialization
  • Implements the base pipe traits

The primary motivation is to create a high-level interface for communicating with a sandbox. In particular, I want to create a compiler interface that supports either in-process or out-of-process builds. Most users, including our build system, will need a sandboxed compiler to recover from LLVM assertion failures and to encapsulate thread-unsafety.

As an example, the final commit includes a test case that treats another process as an actor over stdio.

@brson
Copy link
Contributor Author

brson commented Nov 26, 2012

@eholk, @graydon This may interest you

@brson
Copy link
Contributor Author

brson commented Nov 26, 2012

I made some changes to the generic pipes interface. It's currently split into 4 traits:

  • GenericChan - Contains send, which always succeeds
  • GenericSmartChan - Contains try_send, that reports whether the other end is listening. This is a hard contract to fulfill, and flatpipes don't.
  • GenericPort - recv and try_recv. Both these require that the port be able to detect the situation where the sender dies. With timeouts, most Readers should be able to do this.
  • Peekable - peek, which asks whether recv will succeed w/o blocking. flatpipes don't implement.

@brson
Copy link
Contributor Author

brson commented Nov 26, 2012

Also, the TCP test case is probably the clearest example of how to use net::tcp: brson@fcfdd49#L0R789. Still lots of boilerplate, but I have some ideas how to reduce it to just a few lines.

@graydon
Copy link
Contributor

graydon commented Nov 26, 2012

Nice! I am continually humbled.

/** Receives a message if one is available, or returns `none` if
the connection is closed.

/** Receives a message, or returns `none` if
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: None

@pcwalton
Copy link
Contributor

r=me with comments

@brson
Copy link
Contributor Author

brson commented Dec 18, 2012

I've pushed everything now except the final test case that does IPC over stdio. It has problems on windows that I hope aren't insurmountable, as that was largely the point of the whole exercise.

@brson brson closed this Dec 19, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Nov 21, 2024
use -Zroot-dir instead of --remap-path-prefix for diagnostic dir handling
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.

3 participants