467 Commits

Author SHA1 Message Date
Carl Lerche
2e94b658ed
Track futures tokio-reform branch (#88)
This patch also updates tests and examples to remove deprecated API
usage.
2018-02-01 10:31:07 -08:00
Carl Lerche
b9db119b45
Move tokio-io into the git repository. (#96)
The crates remain separate, but are now developed in the same git
repository using cargo workspaces.

This facilitates making coordinated changes.
2018-01-31 21:06:42 -08:00
Carl Lerche
a87936080b
Limit the max number of registered resources (#95)
* Limit the max number of registered resources

This allows some token space to be used internally. Also, Mio 0.7 will
be limiting the token space some as well.

Mio: https://github.com/carllerche/mio/issues/788

Closes #42
2018-01-31 20:09:44 -08:00
Carl Lerche
65cbfced29
Poll evented mutability (#37)
Generally speaking, it is unsafe to access to perform asynchronous
operations using `&self`. Taking `&self` allows usage from a `Sync`
context, which has unexpected results.

Taking `&mut self` to perform these operations prevents using these
asynchronous values from across tasks (unless they are wrapped in
`RefCell` or `Mutex`.
2018-01-31 20:09:15 -08:00
Carl Lerche
a616220090
Move set_fallback to Reactor from Handle. (#93)
The caller should be required to have control of a reactor when setting
it as a fallback. A `Handle` is used to pass into libraries and
functions and should not grant capability of using the associated
reactor as a fallback.

Closes #71
2018-01-31 12:39:47 -08:00
Carl Lerche
a998367002 Add CHANGELOG stub. 2018-01-30 13:27:12 -08:00
Carl Lerche
c1c06f8ac1 Remove UDP only_v6 accessors. (#94)
These fns are not included on std's UdpSocket.
2018-01-30 15:26:02 -06:00
Carl Lerche
ae627db266 Change net::Incoming signature to match std. (#89)
std's `Incoming` iterator yields `TcpStream` instances. This patch
updates the `Incoming` future to match this signature.

This changes the yielded value from `(TcpStream, SocketAddr)` ->
`TcpStream`.
2018-01-30 15:01:34 -06:00
Carl Lerche
f4ec9a6360 Remove only_v6 from TCP types (#90) 2018-01-30 14:59:23 -06:00
Carl Lerche
0f4706d752 Update send_dgram function signature. (#91)
* Update send_dgram function signature.

All other fns take `&SocketAddr`.

* Fix tests
2018-01-30 14:49:55 -06:00
Carl Lerche
117dcba8cb Remove &addr arg from TcpListener::from_std (#92)
This has been deprecated in mio.
2018-01-30 14:49:32 -06:00
Carl Lerche
fd37fb0f17 Merge remote-tracking branch 'core/master' into new-crate 2018-01-26 14:50:41 -08:00
Carl Lerche
a41c0800f9 Uncomment deny(warnings) 2018-01-26 10:12:19 -08:00
Sean McArthur
e140dabed2 Use 64 iovecs in TcpStream::write_buf (#295) 2018-01-26 09:17:44 -08:00
Alex Crichton
fbdf04f604 More OSX fixes 2018-01-25 07:32:55 -08:00
Alex Crichton
a3c4aec127 Fix compile on OSX 2018-01-22 08:14:05 -08:00
Alex Crichton
730228c8cb
Add debug logs for how long dispatch takes (#81)
I've often found this to be quite useful when debugging why event loops are
stuck or some other bug looks to be in play.
2018-01-18 13:00:53 -06:00
Alex Crichton
826e27685c Delete the IoToken type (#83)
This was added oh-so-long ago and nowadays is just used by one consumer,
`PollEvented`. Let's just inline the already small implementation directly into
`PollEvented` which should make it easier to modify in the future as well
2018-01-18 10:48:59 -08:00
Roman
025f52aadc Fix UdpCodec::encode (#85)
*     Refactor UDP SendDgram & RecvDgram

    Get rid of unnamed structs in the favor of private structs with named fields

*     Change the signature of UdpCodec::encode

    Now it is:

    ```
        fn encode(&mut self, msg: Self::Out, buf: &mut Vec<u8>) -> Result<SocketAddr, Self::Error>;
    ```

    Closes https://github.com/tokio-rs/tokio/issues/79

* Fix compilation error from `mio` crate
2018-01-16 08:49:59 -08:00
Michal 'vorner' Vaner
b081e9593f Get rid of some deprecated warnings (#292)
And allow the others to pass.
2018-01-13 12:03:30 -06:00
Alex Crichton
99fc38e0d6 Bump to 0.1.12 2018-01-08 09:51:05 -08:00
Sean McArthur
ce014943ec add TcpStream::peek (#291) 2018-01-08 11:34:33 -06:00
Alex Crichton
dac13c1df4 Use an events iterator rather than indexing (#82)
Eventually mio won't provide an indexable interface, so switch over to using the
iterator-based interface for now.
2018-01-05 08:47:01 -08:00
Alex Crichton
555c97b313 Expand CI coverage and update README (#80)
Closes #64
2018-01-05 08:43:37 -08:00
Bastien Orivel
b395ccb6d9 Bump dependencies (#289) 2018-01-02 12:03:54 -06:00
Sean Stangl
943cd860cb Use correct project name in README.md. (#288) 2018-01-02 12:03:18 -06:00
Alex Crichton
cde387d7e7 Touch up documentation for Reactor::turn 2017-12-19 14:18:28 -08:00
dethoter
9303076a6b Change a return value of reactor::poll to io::Result. (#40)
* Change a return value of reactor::poll to io::Result.

* Revert "Change a return value of reactor::poll to io::Result."

This reverts commit 281d8c32d44d8971e0aebf3833a72c02273ac3d2.

* Return a result from reactor::poll.

* Drop a reactor if any error occurs. Fix warnings in tests.

* Update a documentation for reactor::turn.

* Unwrap the last turn() call in tests.
2017-12-19 16:15:30 -06:00
Alex Crichton
571e322755 Return a Turn type from the turn method (#60)
This is mostly just future-proofing, the type doesn't actually do anything right
now.
2017-12-13 13:25:20 -06:00
Alex Crichton
4ef772b2db Remove Handle argument from I/O constructors (#61)
This commit removes the `Handle` argument from the following constructors

* `TcpListener::bind`
* `TcpStream::connect`
* `UdpSocket::bind`

The `Handle` argument remains on the various `*_std` constructors as they're
more low-level, but this otherwise is intended to set forth a precedent of by
default not taking `Handle` arguments and instead relying on the global
`Handle::default` return value when necesary.
2017-12-12 18:32:50 -06:00
Alex Crichton
849771ecfa Add a Handle::wakeup method (#59)
This method is intended to be used to wake up the reactor from a remote thread
if necessary, forcing it to return from a blocked call of `turn` or otherwise
prevent the next call to `turn` to from blocking.
2017-12-12 15:19:39 -06:00
Alex Crichton
a577bfc033 Remove the Reactor::run method (#58)
This commit removes the `Reactor::run` method which has previously been used to
execute futures and turn the reactor at the same time. The tests/examples made
heavy usage of this method but they have now all temporarily moved to `wait()`
until the futures dependency is upgraded. In the meantime this'll allow us to
further trim down the `Reactor` APIs to their final state.
2017-12-11 21:29:18 -06:00
Alex Crichton
32f2750c2d Start adding a global event loop
This commit starts to add support for a global event loop by adding a
`Handle::default` method and implementing it. Currently the support is quite
rudimentary and doesn't support features such as shutdown, overriding the return
value of `Handle::default`, etc. Those will come as future commits.
2017-12-11 17:26:39 -06:00
Carl Lerche
c45bbaa04e Bump to v0.1.11 2017-12-11 13:58:30 -06:00
Steven Fackler
963eee3bc7 Add TcpListener::accept_std (#284) 2017-12-07 20:00:49 -06:00
Thomas de Zeeuw
23a0e990d2 return TcpStreamNew for TcpStream::connect_std (#66) 2017-12-06 14:59:57 -06:00
Thomas de Zeeuw
402cd3034d Avoid allocation when return a WouldBlock io::Error (#65) 2017-12-06 10:32:58 -06:00
Thomas de Zeeuw
cf793d4053 Derive debug on public structs (#62)
* Derive Debug on all public structs

* Enable a warning about missing debug implementations on public struct
2017-12-06 10:19:21 -06:00
Alex Crichton
108e1a2c1a Blanket rename Core to Reactor
This commit uses a script to rename `Core` to `Reactor` all at once, notably:

    find . -name '*.rs' | xargs sed -i 's/\bCore\b/Reactor/g'
2017-12-05 09:02:07 -08:00
Alex Crichton
46062794aa Tweak the PollEvented::deregister signature
This commit changes the `PollEvented::deregister` signature from

    fn deregister(self, handle: &Handle) -> io::Result<()>

to

    fn deregister(&self) -> io::Result<()>

Now that the handles are `Send` and `Sync` there's no longer any need to pass it
in (it's already stored in the `PollEvented` itself). Additionally this switches
to `&self` instead of `self` to allow reclamation of the internal resources if
necessary.
2017-12-05 08:54:48 -08:00
Alex Crichton
2e58422890 Add TcpListener::accept_std as a method
This should allow configuration over what reactor accepted streams go on to by
giving back a libstd-bound object that can then be used later in conjunction
with `TcpStream::from_std`.
2017-12-05 08:48:17 -08:00
Alex Crichton
e86fc4917a Change need_read and need_write to return an error
This commit is targeted at solving tokio-rs/tokio-core#12 and incorporates the
solution from tokio-rs/tokio-core#17. Namely the `need_read` and `need_write`
functions on `PollEvented` now return an error when the connected reactor has
gone away and the task cannot be blocked. This will typically naturally
translate to errors being returned by various connected I/O objects and should
help tear down the world in a clean-ish fashion.
2017-12-05 08:43:01 -08:00
Alex Crichton
8fcce957cd Rename networking constructors with _std
This commit renames the various constructors of networking types to have a
`_std` suffix instead of a smorgasboard of other suffixes, canonicalizing on
`_std` as the suffix for constructors which take the libstd corresponding types.
2017-12-05 08:24:26 -08:00
Alex Crichton
259996d805 Remove NEXT_LOOP_ID
This is no longer needed now that the public-facing `CoreId` has been removed
2017-12-05 08:19:47 -08:00
Alex Crichton
329bca15a6 Remove TcpListener::pending_accept field
No need for oneshot shenanigans as now we'll always have the `Handle` available
to us regardless of what thread we're on to associate a new socket
2017-12-05 08:17:08 -08:00
Alex Crichton
7c768fc046 Remove the Remote type
The `Handle` type is now `Send` and `Sync` so the `Remote` type no longer needs
to exist.
2017-12-05 08:15:26 -08:00
Thomas de Zeeuw
c801584d24 Doc improvements (#46)
* small doc cleanups in PollEvented

* small doc cleanups in IoToken

* improve crate level documentation

- Add links to the futures, mio and tokio-uds crates.
- Add links to various structs and types mentioned.
- use eprintln for error reporting in the example.

* improvements to the UdpSocket documentation

- Fixed links usage.
- Removed references to a no longer existing `Window` struct.
- Made notes about using functions in context of a future.

* documentation improvements to UdpFramed and UdpCodec

- Since HTTP uses TCP (QUIC aside) using it as an example in an UDP
protocol feels wrong.
- Make the note of tampering with the underlying streams more explicit.

* update reactor module level documentation

Adds an explanation of every public struct.

* expand Handle and Remote documentation

* expand net module documentation

Adds an explanation of every public struct and how they work together.

* update TcpListener documentation

Reorder the various option methods; get first then set.
Note about panicing added to poll_read.

* remove mention of none-existing future R

* improve documentation of TcpStream

* fix UdpSocket doc

This when wrong when merging various commits.
2017-12-05 09:55:25 -06:00
Thomas de Zeeuw
0b54557796 Remove unused code (#44)
* remove unused #[macro_use] and #[allow(unused_macros)]

* remove unused FnBox trait

* remove unused temporary variable

* remove Evented trait requirement to implement Debug
2017-12-01 15:34:03 -06:00
Alex Crichton
b7ff130a0d Tweak travis config 2017-11-30 18:44:36 -08:00
dethoter
31f8cb9467 Remove Core:id. (#41) 2017-11-21 10:18:11 -08:00