* 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/788Closes#42
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`.
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
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`.
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
* 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
* 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.
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.
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.
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.
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.
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.
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`.
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.
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.
* 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.