3097 Commits

Author SHA1 Message Date
Alex Crichton
32eb457dad Relax the 'static bound on Loop::run
We know that the future will never persist beyond this stack frame, so we can
just leave its ownership on the stack frame itself and receive notifications off
the event loop that we need to poll it.
2016-08-17 23:34:44 -07:00
Alex Crichton
9672f90091 Remove lots of 'static bounds
The core trait and associated types no longer require the `'static` bounds, and
all associated methods have also had the `'static` bounds removed. The only
location for the `'static` bound is `forget`.

While the restriction of `'static` on `forget` is here to stay, we'll soon
enable `Loop::run` to take a non-`'static` future, allowing driving a
non-`'static` future.
2016-08-17 18:48:21 -07:00
Alex Crichton
8025d85019 Update futures-curl
Also involved yet another round of bug fixes to the timer wheel as well as an
unfortunately serious rejiggering of the level-translation into libcurl. Eew.
2016-08-17 18:41:34 -07:00
Alex Crichton
311bfa07a3 Update futures-minihttp 2016-08-17 18:41:34 -07:00
Alex Crichton
d0b911189c Re-work I/O
* 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-17 18:41:34 -07:00
Alex Crichton
293d104177 Remove Future::schedule
A more appealing model is actually just automatically inferring what needs to be
scheduled based on what actions are done during poll. For example if during a
poll you check a oneshot channel, then the current task is registered for being
woken up if it's not ready. Similarly this will apply to I/O where if I/O is
attempted but we see EAGAIN then we'll schedule the task to get notified when
it's ready.

This may also have performance benefits in some niche situations because you
don't need to recompute where you are in the state machine both during poll and
during schedule. Instead, it now happens all at once.
2016-08-17 18:41:34 -07:00
Alex Crichton
62f306629d Keep polling in Buffered if there's more futures
We're not NotReady until we hit the final future and it's not done.
2016-08-15 16:22:09 -07:00
Alex Crichton
217af868e1 Implement UDS bindings
Closes #61
2016-08-15 10:31:23 -07:00
Alex Crichton
8327d327c1 Optimize next_timeout slightly
Avoid moves as it apparently adversely affects perf
2016-08-13 23:29:08 -07:00
Alex Crichton
3158a2c73b Add a method to get a handle from a pin
It's store there anyway!
2016-08-13 23:13:26 -07:00
Alex Crichton
b508964db6 Remove Send from Future/Stream
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-12 15:39:41 -07:00
Alex Crichton
9911f421eb Add LoopPin to easily create LoopData 2016-08-12 13:42:24 -07:00
Alex Crichton
ef3efd4175 Remove the Any bound from LoopData
No need for this, all we need is 'static now
2016-08-12 11:15:34 -07:00
Yale Cason III
0aa7ab94ff Listening vs Listenering
Not trying to be pedantic, just noticed this.
2016-08-11 14:46:16 -04:00
Alex Crichton
f08e8ec672 Fix compile on windows 2016-08-10 22:33:45 -07:00
Alex Crichton
18c371b158 Remove extraneous allocation on ReadinessStream::new 2016-08-10 13:58:20 -07:00
Alex Crichton
517d5c7434 Add libcurl bindings 2016-08-09 23:51:14 -07:00
Alex Crichton
7c4bac5166 Fix a few more timer wheel bugs 2016-08-09 22:13:50 -07:00
Alex Crichton
681316dfa1 Fix link in mio README 2016-08-08 23:20:05 -07:00
Alex Crichton
00daa2ca23 Add lots of README files 2016-08-08 23:18:49 -07:00
Alex Crichton
68103727f1 Use the dev branch of mio 2016-08-08 13:22:16 -07:00
Alex Crichton
bfe91f9f36 Remove the executable bit on a file 2016-08-08 11:44:16 -07:00
Alex Crichton
8d73133907 write-then-drop is now upstream 2016-08-08 11:00:04 -07:00
Alex Crichton
4380e42587 More info and more READMEs 2016-08-05 16:21:56 -07:00
Alex Crichton
164193fe82 Add a method to add data to an event loop directly
Avoids Send entirely
2016-08-05 15:58:14 -07:00
Alex Crichton
8daac0347d Fix up a few edge cases on the timer wheel 2016-08-05 14:02:27 -07:00
Alex Crichton
d2bb8e01fd Implement Sync for LoopData
It's already Sync because it's safe to access amongst many threads by the sheer
fact that data is only accessed on one thread. That is, all other concurrent
accessors, if any, will receive `None`.
2016-08-05 14:01:36 -07:00
Alex Crichton
5b18514970 Add some assorted debug messages 2016-08-05 14:01:24 -07:00
Alex Crichton
42a0a10294 Set the CURRENT_LOOP for processing messages
This ensures that timeouts and callbacks are run with the TLS var set
2016-08-05 14:00:59 -07:00
Alex Crichton
304914b707 Start brushing up io/mio docs 2016-08-05 09:53:50 -07:00
Alex Crichton
8eb1f681af Don't export the timer_wheel module
Move tests into that module
2016-08-05 09:44:00 -07:00
Alex Crichton
368a9c70e8 Fix RefCell borrow_mut error on firing timeouts
The scope was a little longer than intended!
2016-08-05 09:38:41 -07:00
Alex Crichton
5d0fdf26a9 Fix compile of minihttp on stable 2016-08-05 09:25:40 -07:00
Alex Crichton
e7f4313cf4 Implementing LoopData
This type acts for a handle to storage of non-`Send` data. The handle itself is
sendable across threads and is therefore suitable for storage in a `Future`.
This data uses communication internally and a new method on `Task` to ensure
that when the data needs to be accessed the future will find its way to the
right thread.

More on this type coming soon!
2016-08-04 20:34:54 -07:00
Alex Crichton
04bd33e390 Add AsRawFd where possible 2016-08-04 12:51:49 -07:00
Alex Crichton
5f9185ef4c Fix timer wheel tests 2016-08-03 23:38:32 -07:00
Alex Crichton
5c9daad88b Add a timer wheel 2016-08-03 22:57:07 -07:00
Alex Crichton
1d7098eece Add a simple UDP test 2016-08-02 23:56:01 -07:00
Alex Crichton
c458e23940 Add a few more TCP methods 2016-08-02 22:52:01 -07:00
Alex Crichton
260255e674 Add UDP sockets 2016-08-02 22:49:58 -07:00
Alex Crichton
1b07e91834 Actually do what EventLoop::deschedule says 2016-08-02 10:39:06 -07:00
Alex Crichton
79760da66c Remove DropSource from mio
I'm... not sure if it does anything any more as a `ReadinessStream` isn't
clone-able nor is it split. As a result, I don't think we need it.
2016-08-02 10:37:32 -07:00
Alex Crichton
5970203b21 Finish docs on futures-mio
Also remove mio BufReader/BufWriter for now, they should come back shortly
though
2016-08-01 17:41:58 -07:00
Alex Crichton
7ffe72dc73 Add docs to futures-io crate 2016-08-01 17:30:56 -07:00
Alex Crichton
b47b9f5398 Remove README descriptions where not present 2016-07-31 13:58:38 -07:00
Alex Crichton
192579d62a Add some descriptions 2016-07-31 13:55:04 -07:00
Alex Crichton
bc64194be1 Let's rename everything! 2016-07-30 22:50:58 -07:00