summaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)Author
2018-08-10Routine dependencies update (#533)Mateusz Mikuła
* Update dependencies * Replace deprecated tempdir with tempfile
2018-08-09Remove dead futures2 code. (#538)Carl Lerche
The futures 0.2 crate is not intended for widespread usage. Also, the futures team is exploring the compat shim route. If futures 0.3 support is added to Tokio 0.1, then a different integration route will be explored, making the current code unhelpful.
2018-07-24Count in-transit spawned futures to current thread executor as pending (#478)Jon Gjengset
2018-07-11Add free block_on_all in current thread Runtime (#477)Jon Gjengset
2018-06-21Fix unneeded mut and some deprecated api (#442)Roman
2018-06-14runtime: add block_on_all (#398)Marc-Antoine Perennou
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2018-06-12tokio-current-thread crate (#370)jpbriquet
Extract `tokio::executor::current_thread` to a tokio-current-thread crate. Deprecated fns stay in the old location. The new crate only contains thee most recent API.
2018-06-12Fix a deadlock that can happen when shutting down (#409)Carl Lerche
There is a deadlock that can occur when the concurrent runtime shuts down. This patch adds a test and fix. Fixes #401.
2018-06-06Another attempt at abstracting `Instant::now` (#381)Carl Lerche
Currently, the timer uses a `Now` trait to abstract the source of time. This allows time to be mocked out. However, the current implementation has a number of limitations as represented by #288 and #296. The main issues are that `Now` requires `&mut self` which prevents a value from being easily used in a concurrent environment. Also, when wanting to write code that is abstract over the source of time, generics get out of hand. This patch provides an alternate solution. A new type, `Clock` is provided which defaults to `Instant::now` as the source of time, but allows configuring the actual source using a new iteration of the `Now` trait. This time, `Now` is `Send + Sync + 'static`. Internally, `Clock` stores the now value in an `Arc<Now>` value, which introduces dynamism and allows `Clock` values to be cloned and be `Sync`. Also, the current clock can be set for the current execution context using the `with_default` pattern. Because using the `Instant::now` will be the most common case by far, it is special cased in order to avoid the need to allocate an `Arc` and use dynamic dispatch.
2018-06-05Implement a Send Handle for the single-threaded Runtime (#340)Sebastian Dröge
Implement a Send'able Handle for the single-threaded `Runtime` and `CurrentThread` executor to spawn new tasks from other threads.
2018-06-04Create tokio-codec (#360)Bryan Burgers
Create a new tokio-codec crate with many of the contents of `tokio_io::codec`.
2018-06-04Implement Runtime::block_on using oneshot (#391)Jon Gjengset
2018-05-02Current thread runtime (#308)Roman
This patch introduces a version of `Runtime` that runs all components on the current thread. This allows users to spawn futures that do not implement `Send`.
2018-04-25Make CurrentThread::turn() more fair by always parking with 0 timeout… (#313)Sebastian Dröge
This ensures that all fd-based futures are put into the queue for the current tick, if the CurrentThread is parking via the Reactor. Otherwise, if there are queued up futures already, only those would be polled in the turn. These futures could then notify others/themselves to have the queue still non-empty on the next turn. Which then potentially allows the reactor to never be polled, and thus fd-based futures are never queued up and polled. Also return in the Turn return value whether any futures were polled at all, which allows the caller to know if any work was done at all in this turn and based on that adjust behavior.
2018-03-30Rename `Sleep` to `Delay` (#270)Carl Lerche
This patch renames `Sleep` from tokio-timer and the tokio facade to `Delay`. Given that the future does not actually put anything to sleep, the `Delay` name feels more appropriate. Fixes #263
2018-03-30Integrate timers with runtime. (#266)Carl Lerche
This patch integrate the new timer implementation with the runtime by initializing a timer per worker thread. This allows minimizing the amount of synchronization needed for using timers.
2018-03-29Remove println from tests (#267)Carl Lerche
2018-03-29Fix permissions (#268)Carl Lerche
2018-03-23Change hammer test consts (#255)Carl Lerche
2018-03-22Fix race condition related bugs (#243)Carl Lerche
* 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.
2018-03-21Update to futures 0.2.0-beta (#246)Aaron Turon
2018-03-15Add top-level tests for futures 0.2 integration (#231)Aaron Turon
2018-03-14Move tokio::net module into tokio tcp/udp crates (#224)Sam Rijs
2018-03-13Simultaneous futures compat (#172)Aaron Turon
This patch adds opt-in support for futures 0.2.
2018-03-11Remove uses of futures_cpupool (#220)Jeehoon Kang
2018-03-07Improve `poll_read_ready` implementation (#193)Carl Lerche
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.
2018-03-04Switch TCP/UDP fns to poll_ -> Poll<...> style (#175)Carl Lerche
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.
2018-03-02Tweak the `tokio::spawn` function (#171)Carl Lerche
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.
2018-03-01Fix deprecation warnings in tests (#167)Carl Lerche
2018-02-28I/O resources lazily bind to reactor. (#160)Carl Lerche
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.
2018-02-28Improve current thread tests (#161)Roman
* Create variables as closer as possible to their usage * Check that no message is lost in test current_thread::hammer_turn
2018-02-27Support current_thread::spawn from task drop (#157)Carl Lerche
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.
2018-02-26Fix race condition in CurrentThread. (#156)Carl Lerche
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.
2018-02-23Fix bug with CurrentThread::turn (#152)Carl Lerche
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.
2018-02-21Introduce the Tokio runtime: Reactor + Threadpool (#141)Carl Lerche
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.
2018-02-07Make `Handle::wakeup` private (#117)Carl Lerche
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.
2018-02-07Remove `framed` fn from `UdpSocket` (#116)Carl Lerche
Instead, use `UdpFramed::new` to create a framed wrapper around the UDP socket.
2018-02-06Remove UdpCodec (#109)Roman
`UdpFramed` is updated to use the `Encoder` and `Decoder` traits from `tokio-io`.
2018-02-06Switch back to futures from crates.io (#113)Carl Lerche
Doing so requires copying the `current_thread` executor from GitHub into the repo.
2018-02-01Track futures tokio-reform branch (#88)Carl Lerche
This patch also updates tests and examples to remove deprecated API usage.
2018-01-31Poll evented mutability (#37)Carl Lerche
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-30Change `net::Incoming` signature to match std. (#89)Carl Lerche
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-30Update send_dgram function signature. (#91)Carl Lerche
* Update send_dgram function signature. All other fns take `&SocketAddr`. * Fix tests
2018-01-30Remove &addr arg from TcpListener::from_std (#92)Carl Lerche
This has been deprecated in mio.
2018-01-16Fix UdpCodec::encode (#85)Roman
* 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
2017-12-19Change a return value of reactor::poll to io::Result. (#40)dethoter
* 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-12Remove `Handle` argument from I/O constructors (#61)Alex Crichton
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-12Add a `Handle::wakeup` method (#59)Alex Crichton
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-11Remove the `Reactor::run` method (#58)Alex Crichton
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-11Start adding a global event loopAlex Crichton
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.