510 Commits

Author SHA1 Message Date
Roman
56c5797872 Split net::udp code into files: (#183)
- UdpSocket -> src/net/udp/socket.rs
- SendDgram -> src/net/udp/send_dgram.rs
- RecvDgram -> src/net/udp/recv_dgram.rs
2018-03-06 09:53:23 -08:00
Jeehoon Kang
aa4b1b4311 Replace coco with crossbeam (#185) 2018-03-06 09:49:01 -08:00
Roman
687871d3e5 Split net::tcp code into files: (#177)
- Incoming -> src/net/tcp/incoming.rs
- TcpListener -> src/net/tcp/listener.rs
- TcpStream, ConnectFuture -> src/net/tcp/stream.rs
2018-03-05 12:44:09 -08:00
Philip Munksgaard
071d8704ce Fix typos (#176) 2018-03-05 11:12:43 -08:00
Carl Lerche
9f7a98af3c
Switch TCP/UDP fns to poll_ -> Poll<...> style (#175)
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-04 10:46:54 -08:00
Carl Lerche
7db7719419
Tweak the tokio::spawn function (#171)
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-02 15:45:35 -08:00
Carl Lerche
21c0f3a9d8
Add AsyncRead::poll_read, AsyncWrite::poll_write. (#170)
This removes the need for the `try_nb` macro as well as bring the traits
closer in line with the planed 0.2 iteration.
2018-03-02 15:15:05 -08:00
Carl Lerche
e1b3085153
Extract the reactor to a dedicated crate. (#169)
This allows libraries that require access to reactor related types to
depend on this crate without having to depend on the entirety of Tokio.

For example, libraries that implement their custom I/O resource will
need to access `Registration` or `PollEvented`.
2018-03-02 13:51:34 -08:00
Carl Lerche
df6e24255b
Fix deprecation warnings in tests (#167) 2018-03-01 21:50:07 -08:00
Carl Lerche
df19119c0a
Add io facade and update reactor docs (#166)
This patch updates the documentation for a number of APIs. It also
introduces a prelude module and an io facade module, re-exporting types
from tokio-io.
2018-03-01 21:48:18 -08:00
Carl Lerche
164ee8f106
Update the README (#164) 2018-02-28 15:03:45 -08:00
Carl Lerche
7238cfa5e2
Update AppVeyor badge URL (#163) 2018-02-28 13:48:08 -08:00
Carl Lerche
7de749b77b
Provide a handle to Runtime's executor. (#162)
Sometimes, passing ownership to an executor is necessary. For example,
some libraries require taking ownership of one.

This patch adds a function that returns an executor associated with a
runtime.
2018-02-28 09:07:14 -08:00
Carl Lerche
2eabc37599
I/O resources lazily bind to reactor. (#160)
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-28 09:03:13 -08:00
Roman
1190176be7 Improve current thread tests (#161)
* Create variables as closer as possible to their usage
* Check that no message is lost in test current_thread::hammer_turn
2018-02-28 09:00:25 -08:00
Carl Lerche
8e1a9101f0
Support current_thread::spawn from task drop (#157)
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-27 09:56:29 -08:00
Roman
427b7325d0 Update badges in README (#159) 2018-02-27 09:35:50 -08:00
Carl Lerche
2961a2388c
Fix race condition in CurrentThread. (#156)
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-26 20:41:06 -08:00
Carl Lerche
df3a92532b
Only deploy docs on linux. Take 2 (#155)
Try using an env var to enforce the doc deploy condition.
2018-02-26 14:50:07 -08:00
Carl Lerche
23f451e8b1
Only deploy docs on linux (#154) 2018-02-26 14:12:41 -08:00
Ben Boeckel
40cbd0f296 length_delimited: add a native_endian builder method (#144)
This method is useful when reading from a operating system service.
2018-02-26 10:38:56 -08:00
Alan Somers
3b64fe9363 Lio3 (#142)
FreeBSD uses a separate kqueue filter type for lio_listio.  This change
adds support for that filter type.  Full functionality will be provided
by the mio-aio and tokio-file crates.

* Add PollEvented::into_inner

Consumes a PollEvented and returns its inner io object.  Useful for io
types that have exclusive ownership of a resource.

See also https://github.com/tokio-rs/tokio-core/commit/9400ffb
2018-02-26 09:39:57 -08:00
Carl Lerche
5334de5e44
Fix bug with CurrentThread::turn (#152)
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-23 22:15:46 -08:00
Carl Lerche
fe14e7b127
Introduce the Tokio runtime: Reactor + Threadpool (#141)
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-21 07:42:22 -08:00
Carl Lerche
e0d95aa037 Update root license file 2018-02-20 15:13:52 -08:00
cetra3
dc225faf24 Adjust handle documentation (#140) 2018-02-14 14:23:39 -08:00
Roman
8605d5d243 Make benches compilable again (#133) 2018-02-13 10:02:06 -08:00
Carl Lerche
4704f61277
Remove references to Remote (#135)
Fixes #121
2018-02-12 14:13:11 -08:00
Roman
88a7030f73 Split io code (#129)
* move src/io.rs -> src/io/mod.rs
* move src/read.rs -> src/io/read.rs
* move src/read_exact.rs -> src/io/read_exact.rs
* move src/read_until.rs -> src/io/read_until.rs
* move src/read_to_end.rs -> src/io/read_to_end.rs
* move src/flush.rs -> src/io/flush.rs
* move src/copy.rs -> src/io/copy.rs
* move src/shutdown.rs -> src/io/shutdown.rs
* move src/write_all.rs -> src/io/write_all.rs
* move Async{Read,Write} => src/io/async_{read,write}.rs
* move Async{Read,Write} => src/async_{read,write}.rs
2018-02-12 09:52:05 -08:00
Roman
35aeabd3ff Split codec code (#128)
* move src/codec.rs -> src/codec/mod.rs
* Move traits Encoder and Decoder from src/framed_{read|write}.rs into src/codec/{encoder,decoder}.rs
* Move LinesCodec and BytesCodec from src/codecs.rs into src/codec/{lines,bytes}_codec.rs
2018-02-12 09:10:19 -08:00
Carl Lerche
0b58bded7c
Bump version to v0.1.1 (#131) tokio-0.1.1 2018-02-09 14:30:32 -08:00
Carl Lerche
609786ed41
Remove fn that was never intended to be pub (#130)
This function could not be called from a public setting in the first
place due to the argument types being private.
2018-02-09 11:32:38 -08:00
Carl Lerche
a9da59882c
Fix example doc comment (#124)
Fixes #123
2018-02-08 09:09:02 -08:00
Carl Lerche
4ae76132c1
Update the required Mio point release. (#120)
Tokio depends on the latest Mio point release, so update Cargo.toml to
reflect this.
2018-02-07 14:45:12 -08:00
Carl Lerche
23bc9d20d3
Prepare for tokio 0.1 release (#119) tokio-io-0.1.5 tokio-0.1.0 2018-02-07 13:28:29 -08:00
Carl Lerche
c225b46b18
Make Handle::wakeup private (#117)
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-07 11:09:44 -08:00
Carl Lerche
c30fa62dda
Remove framed fn from UdpSocket (#116)
Instead, use `UdpFramed::new` to create a framed wrapper around the UDP
socket.
2018-02-07 10:42:27 -08:00
Roman
ad8338e4da Remove UdpCodec (#109)
`UdpFramed` is updated to use the `Encoder` and
`Decoder` traits from `tokio-io`.
2018-02-06 13:41:31 -08:00
cssivision
73b763f69f Fix: struct shoutdown ignore Async::NotReady (#114) 2018-02-06 13:30:05 -08:00
Carl Lerche
f0ea9d6f4c
Switch back to futures from crates.io (#113)
Doing so requires copying the `current_thread` executor from GitHub into
the repo.
2018-02-06 07:26:21 -08:00
Carl Lerche
567887cc75
Add a chat example (#112) 2018-02-05 20:45:12 -08:00
Roman
3840ceafee Rename TcpStreamNew -> ConnectFuture (#111) 2018-02-05 20:09:00 -08:00
Carl Lerche
a5e9c311bf
Fix link to documentation in README (#108) 2018-02-02 13:46:15 -08:00
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