Age | Commit message (Collapse) | Author |
|
|
|
|
|
* Fix races.
This mostly pulls in changes from rust-lang-nursery/futures-rs#881, but
also updates Registration to be a bit more obvious as to what is going
on.
* Reduce spurious wakeups caused by Reactor
This patch adds an ABA guard on token values before registering them
with Mio. This allows catching token reuse and avoid the notification.
This is needed for OS X as the notification is used to determine that a
TCP connect has completed. A spurious notification can potentially cause
write failures.
|
|
|
|
|
|
|
|
This patch adds opt-in support for futures 0.2.
|
|
|
|
This patch updates `poll_read_ready` to take a `mask` argument, enabling
the caller to specify the desired readiness. `need_read` is renamed to
`clear_read_ready` and also takes a mask.
This enables a caller to listen for HUP events without requiring reading
from the I/O resource.
|
|
Tokio is moving away from using `WouldBlock`, instead favoring
`Async::NotReady`.
This patch updates the TCP and UDP types, deprecating any function that
returns `WouldBlock` and adding a poll_ prefixed equivalent.
|
|
Currently, `tokio::spawn` matched the `spawn` function from futures 0.2.
However, this adds additional ergonomic overhead and removes the ability
to spawn from a drop fn. See rust-lang-nursery/futures-rs#830.
This patch switches the behavior to access the thread-local variable
referencing the default executor directly in the `spawn` function.
|
|
|
|
This patch makes a significant change to how I/O resources bind to a
reactor. Currently, an I/O resource (TCP, UDP, PollEvented) will bind
itself with a reactor upon creation.
First, some history.
Originally, tokio-core required that I/O resources be explicitly
associated with a reactor upon creation by passing in a `&Handle`. Tokio
reform introduced a default reactor. If I/O resources do not specify a
reactor upon creation, then the default reactor is used.
However, futures tend to favor being lazy. Creating a future should do
no work, instead it is defining a computation to be performed once the
future is executed. Binding an I/O resource with a reactor on creation
goes against this pattern.
This patch fixes this by allowing I/O resources to lazily bind to a
reactor. An explicit `&Handle` can still be used on creation, but if no
reactor is specified, then the default reactor is used. However, this
binding happens during execution time (read / write) and not creation.
|
|
* Create variables as closer as possible to their usage
* Check that no message is lost in test current_thread::hammer_turn
|
|
Currently, the thread-local tracking the current thread executor is not
set when a task is dropped. This means that one cannot spawn a new
future from within the drop implementation of another future.
This patch adds support for this by setting the thread-local before
releasing a task.
This implementation is a bit messy. It probably could be cleaned up, but
this is being put off in favor of trying a more comprehensive
reorganization once the current thread executor is feature complete.
|
|
The logic that enables `CurrentThread::turn` to avoid unbounded
iteration was incorrect. It was possible for unfortunate timing to
result in a dead lock.
This patch provides a fix as well as a test.
|
|
CurrentThread::turn uses a turn count strategy to allow `turn` to not
run infinitely. Currently, there is a bug where spawned tasks will not
get executed in calls to `turn`.
This patch fixes the bug by correctly setting the turn count for newly
spawned tasks.
|
|
This patch is an intial implementation of the Tokio runtime. The Tokio
runtime provides an out of the box configuration for running I/O heavy
asynchronous applications.
As of now, the Tokio runtime is a combination of a work-stealing thread
pool as well as a background reactor to drive I/O resources.
This patch also includes tokio-executor, a hopefully short lived crate
that is based on the futures 0.2 executor RFC.
* Implement `Park` for `Reactor`
This enables the reactor to be used as the thread parker for executors.
This also adds an `Error` component to `Park`. With this change, a
`Reactor` and a `CurrentThread` can be combined to achieve the
capabilities of tokio-core.
|
|
The `Handle` type is intended to be used by end users of Tokio. The
wakeup functionlity is needed by executor implementations. It doesn't
make sense to put executor specific functionality on a type that is
intended for end users.
|
|
Instead, use `UdpFramed::new` to create a framed wrapper around the UDP
socket.
|
|
`UdpFramed` is updated to use the `Encoder` and
`Decoder` traits from `tokio-io`.
|
|
Doing so requires copying the `current_thread` executor from GitHub into
the repo.
|
|
This patch also updates tests and examples to remove deprecated API
usage.
|
|
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`.
|
|
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`.
|
|
* Update send_dgram function signature.
All other fns take `&SocketAddr`.
* Fix tests
|
|
This has been deprecated in mio.
|
|
* 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 uses a script to rename `Core` to `Reactor` all at once, notably:
find . -name '*.rs' | xargs sed -i 's/\bCore\b/Reactor/g'
|
|
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.
|
|
* remove unused #[macro_use] and #[allow(unused_macros)]
* remove unused FnBox trait
* remove unused temporary variable
* remove Evented trait requirement to implement Debug
|
|
In accordance with tokio-rs/tokio-rfcs#3, the executor functionality of
Tokio is being removed and will be relocated into futures-rs as a
"current thread" executor.
This PR removes task execution from the code base. As a temporary
mesure, all examples and tests are switched to using CpuPool.
Depends on #19.
|
|
In accordance with tokio-rs/tokio-rfcs#3, timers are being extracted
from Tokio and moved to a separate crate (probably futures-timer).
This PR removes timers from the code base.
|
|
This commit removes code that was deprecated in tokio-core master.
|
|
|
|
|
|
|
|
UDP 0-length datagrams
|
|
Resolves #248, preventing UdpFramed from sending 0-length datagrams.
Also, adds 0-length tests for UdpSocket.
|
|
|
|
|
|
Otherwise we may accidentally hold the borrowed ref cell for too long which can
cause a borrow error.
Closes #190
|
|
Deprecate the existing `io` module in this crate entirely.
More details coming soon!
Closes #61
|
|
|
|
|