Commit Graph
45 Commits
Author SHA1 Message Date
Carl Lerche 4c268a8939 Make Handle Send + Sync. (#35)
* Make Handle `Send + Sync`.

This is an initial implementation making `Handle: Send + Sync`. It uses
a `RwLock` to coordinate access to the underlying state storage. An
implementation without the lock is left to later.

This pass also leaves a lot of dead code that can be removed in later
commits.

* Remove reactor code related to message passing

The previous commit removed the need for using message passing to
communicate with the reactor. This commit removes all the unnecessary
code.
2017-11-17 12:51:23 -08:00
Carl Lerche c6f1ff13d2 Remove executor from reactor.
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.
2017-11-01 07:28:49 -07:00
Carl Lerche 697851210c Remove timers from Tokio.
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.
2017-10-30 18:16:00 -07:00
Alex Crichton 97d80296cb Conditionally call consume_queue on messages
The `consume_queue` function can be relatively slow for an empty queue (the fast
path) so optimize this a bit with a preflight check that should just touch a few
atomics.
2017-09-12 21:42:22 -07:00
Travis Bischel fce59de79e bump slab to 0.4.0
Makes some of the code easier to read.
2017-09-07 20:53:54 -07:00
Alex Crichton e8617ea1fc Update futures dependency 2017-08-24 08:16:04 -07:00
Raph Levien 05b1ba4342 [fuchsia] Config changes to build on Fuchsia
This patch disables various Unix-specific platform features that are
not enabled on Fuchsia. It also updates the mio version to 0.6.10,
which is the first release that supports Fuchsia.
2017-07-31 14:12:53 -07:00
manuels d03c736b4c Add documentation about panics to {Handle, Remote}::spawn{fn} 2017-07-26 17:33:09 +02:00
Alex Crichton c65c331767 Merge pull request #210 from asomers/aio5
POSIX AIO support, try 2
2017-06-08 14:30:22 -05:00
Alan Somers 363e15f36c Respond to alexchrichton's comments
* Combine the FreeBSD/Dragonfly platform with the other Unix platform
* Remove the Windows platform::aio method
* Update deps
2017-06-07 22:36:32 -06:00
Alex Crichton 16d15520ad Update tokio-core with new task system 2017-05-30 08:42:32 -07:00
Alan Somers 42f73cb0ec Revert changes to read_ready and add platform::all() 2017-05-21 11:01:48 -06:00
Alan Somers 81beb44565 POSIX AIO support, try 2
Support POSIX AIO, post-01635df .  A concrete implementation will be
added by the mio-aio and tokio-file crates
2017-05-21 10:24:08 -06:00
Alex Crichton 4dd3d30f2a Add PollEvented::poll_ready
This commit adds a general-purpose method for querying the readiness of a
`PollEvented` type. This new method, `poll_ready`, takes a blanket `mio::Ready`
and tests if any part of it is ready. The purpose of this is to expose
platform-specific events through `PollReady` such as `hup` and `error` events
other than just the platform-agnostic readable/writable events.

The semanatics of this method are:

* The `poll_ready` function takes a mask, and the return value is either
  `Async::Ready` with a subset of these events that are ready or `None` if none
  of them are ready.
* There can be up to two tasks blocked on a `PollEvented`, so we need to pick
  which one is suitable for these new events. Currently all events are routed to
  the `read` task unless the writable bit is set. This is mostly only relevant
  for multi-task usage or if you're manually calling `need_read` and/or
  `need_write`, and hopefully the docs will cover this now.
2017-05-19 11:23:00 -07:00
king6cong 4d8d293913 typo fix 2017-05-12 18:00:55 +08:00
Nikolay Kim 0cfa98566e drop inner borrow before dropping task 2017-05-07 21:17:57 -07:00
Alex Crichton 37e2870f04 Limit the scope of borrow_mut in consume_queue
Otherwise we may accidentally hold the borrowed ref cell for too long which can
cause a borrow error.

Closes #190
2017-03-15 22:59:08 -07:00
Alex Crichton 89fcc96dd4 Migrate to using tokio-io
Deprecate the existing `io` module in this crate entirely.

More details coming soon!

Closes #61
2017-03-15 09:46:54 -07:00
Alex Crichton b0d04e04f2 Merge pull request #174 from asomers/aioprep
Replace magic numbers with constants from mio
2017-03-07 08:58:37 -06:00
Alex Crichton 5c411c548b Add Debug for {Handle,Remote,Core}
Closes #170
2017-03-06 12:16:09 -08:00
Alan Somers 3b8f1695ff Define constants to replace magic numbers 2017-03-05 14:38:55 -07:00
Denis Andrejew 1722d8ed45 fix typo in reactor::Core::run docs 2017-03-03 18:38:56 +00:00
Jan Zerebecki e8bd2117d0 Fix typo in docblock for Core::run() 2017-02-27 11:07:19 +01:00
Alex Crichton b22b797278 Add a function to upgrade a Remote to a Handle
Intended for fast paths which can be a little more optimized for when they're
run directly on the event loop.
2017-01-23 20:11:37 -08:00
Alex Crichton e69b67fcfe Remove extraneous clone in Remote 2017-01-23 20:06:03 -08:00
Michal 'vorner' Vaner 8d02a1c2b6 Provide a publicly-accessible Core ID
Allow distinguishing between multiple `Core`s and associating data with
them through a `HashMap` or similar.
2017-01-17 22:09:31 +01:00
Alex Crichton d0833074d6 Move from a custom channel to futures::sync
Closes #143
2017-01-11 11:35:45 -08:00
critiqjo 372d55ce0b Docs: Remove outdated reference to task::poll_on 2017-01-10 10:09:47 +05:30
critiqjo e5bbf004d3 Update the use of deprecated APIs
For stuff that moved from futures::task to futures::executor
2017-01-05 20:41:36 +05:30
David Renshaw 7abe6db0ae initialize slabs with capacity of one 2016-12-16 13:37:59 -05:00
Andreas Rottmann 5bab8e85b9 Handle hup events as indicating read readiness
Using Linux's `epoll(7)` interface, a `EPOLLHUP` condition is
signalled for the reading end of a pipe or socket when the other end
is closed for writing. This may happen in combination with `EPOLLIN`
being signalled (if further data is available for reading), or with
`EPOLLIN`.

If `EPOLLHUP` is signalled without `EPOLLIN` it indicates an immediate
EOF condition, which will result in the next `read()` suceeding with 0
bytes read. It is thus not required to handle `EPOLLHUP` specially in
the reader, but we need to indicate readiness upon encountering it.

Looking at the `kqueue` and `windows` mio backends, they seem to be
turn a detected EOF and connection reset into `mio::Ready::hup()`
events, so it may be reasonable to speculate that this change is an
improvement for these platforms as well.

Fixes #117.
2016-12-08 17:52:40 +01:00
Alex Crichton f6241b6330 Touch up Reactor::poll 2016-11-11 14:27:49 -08:00
Alex Crichton 092574b7de Merge branch 'aphs-core-stream' of https://github.com/aidanhs/tokio-core 2016-11-11 14:06:03 -08:00
Aidan Hobson Sayers fce913c04d Add turn on Core to allow single event loop iterations 2016-11-06 22:11:18 +00:00
David Renshaw f96d37ccf3 Fix some typos. 2016-11-05 16:29:54 -04:00
Alex Crichton 0a3dc0bb75 Add a method to manually deregister an I/O object
Typically this happens automatically as the `E` in `PollEvented<E>` is an owned
reference (e.g. a `TcpStream`) where dropping that will close the resource,
automatically unregistering it from the event loop. In some situations, however,
this isn't always the case, so the deregistering needs to happen manually.
2016-11-04 09:12:00 -07:00
Paul Colomiets b1d02eb598 Implement tokio_core::reactor::Interval 2016-10-10 15:41:57 +03:00
Paul Colomiets 411caa786d Moves when to Timeout from TimeoutToken 2016-10-06 21:11:46 +03:00
oberien f62d1ddc8d doc(spawn_fn): Fix typo 2016-09-28 03:20:33 +02:00
Alex Crichton 1d40bf14f7 Add Handle::spawn_fn
Acts as a convenience to avoid `futures::lazy`.

Closes #40
2016-09-26 16:52:54 -07:00
Moritz Gunz 326537b861 Fix documentation typos 2016-09-21 18:27:25 +02:00
Alex Crichton 83784fd983 Don't remove timeouts that have fired
Closes #22
2016-09-08 07:47:07 -07:00
Alex Crichton 1f0d2198ad Use a timer heap instead of a timer wheel
In general it's easier to implement and should have more predictable performance
semantics for applications in general. More serious timer usage can go through
`tokio-timer` which has properly configurable timer wheels and such.

Closes #2
Closes #7
2016-09-08 00:06:34 -07:00
Alex Crichton 66cff8e84b Swap Handle/Pinned
* Handle -> Remote
* Pinned -> Handle

All APIs now take a `&Handle` by default and in general can return an immediate
`io::Result` instead of an `IoFuture`. This reflects how most usage will likely
be done through handles rather than remotes, and also all previous functionality
can be recovered with a `oneshot` plus `Remote::spawn`.

Closes #15
2016-09-07 22:12:41 -07:00
Alex Crichton 6c045d31ac Reorganize the entire crate:
Renamed APIs

* Loop => reactor::Core
* LoopHandle => reactor::Handle
* LoopPin => reactor::Pinned
* TcpStream => net::TcpStream
* TcpListener => net::TcpListener
* UdpSocket => net::UdpSocket
* Sender => channel::Sender
* Receiver => channel::Receiver
* Timeout => reactor::Timeout
* ReadinessStream => reactor::PollEvented
* All `LoopHandle` methods to construct objects are now free functions on the
  associated types, e.g. `LoopHandle::tcp_listen` is now `TcpListener::bind`
* All APIs taking a `Handle` now take a `Handle` as the last argument
* All future-returning APIs now return concrete types instead of trait objects

Added APIs

* io::Io trait -- Read + Write + ability to poll

Removed without replacement:

* AddSource
* AddTimeout
* IoToken
* TimeoutToken

Closes #3
Closes #6
2016-09-07 22:12:14 -07:00