summaryrefslogtreecommitdiffstats
path: root/src/bin/sink.rs
AgeCommit message (Collapse)Author
2016-08-18Rewrite recursion with a loop in sink.rsAlex Crichton
2016-08-17Re-work I/OAlex Crichton
* Auto-register interest whenever we see WouldBlock * Remove implementations of `Stream<Item=Ready>`, no longer needed * Add explicit `poll_{read,write}` methods, if needed * Remove all I/O streams, libstd ones suffice * Update all I/O futures
2016-08-12Remove Send from Future/StreamAlex Crichton
This bound existed for two primary reasons, both detail below, and both of which have now been solved. One of the primary reasons this existed was due to the presence of `tailcall`. Each standard combinator will call `tailcall` as appropriate, storing the resulting trait object. Storing trait objects influences the applicatoin of the `Send` and `Sync` bounds normally, but a key insight here is that we're not storing trait objects but rather just pieces of otherwise internal futures. With this insight the main storage for these futures, `Collapsed`, could simply implement `Send` so long as the future itself originally implemented `Send`. This in turn means that `tailcall` must be an `unsafe` method, but it seems well worth the benefit of relaxing the `Send` bound. The second primary reason for this bound was so the `Task` itself could be send. This is critical for ensuring that futures can receive notifications from multiple threads (e.g. be a future waiting on sources of multiple events). Another key insight here, however, is that only the *outer* future needs to be `Send`. We already have a solution, with `LoopData`, to make non-`Send` data `Send`. By implementing `Future` directly for `LoopData<F: Future>`, this means that it's trivial to make any future sendable by simply pinning it to an event loop! With these two pieces combined, it means that `Send` is no longer needed as a bound on the `Future` and `Stream` traits. It may practically mean that `LoopData` is used commonly in some scenarios, but that's quite a small price to pay for relaxing the requirements of the core trait. Some other ramifications of this change are: * The `Future::boxed` and `Stream::boxed` methods now require `Self` to adhere to `Send`. This is expected to be the most common case, and in the less common case of not-`Send` `Box::new` can be used. * Two new type aliases, `BoxFuture` and `BoxStream` have been introduced to assist in writing APIs that return a trait object which is `Send`. Both of these type aliases package in the `Send` bound. * A new `LoopPin` type, added in the previous commit, can be used to easily generate handles that can be used to pin futures to an event loop without having a literal reference to the event loop itself.
2016-08-01Finish docs on futures-mioAlex Crichton
Also remove mio BufReader/BufWriter for now, they should come back shortly though
2016-07-30Let's rename everything!Alex Crichton