431 Commits

Author SHA1 Message Date
Alex Crichton
a577bfc033 Remove the Reactor::run method (#58)
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-11 21:29:18 -06:00
Alex Crichton
32f2750c2d Start adding a global event loop
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.
2017-12-11 17:26:39 -06:00
Thomas de Zeeuw
23a0e990d2 return TcpStreamNew for TcpStream::connect_std (#66) 2017-12-06 14:59:57 -06:00
Thomas de Zeeuw
402cd3034d Avoid allocation when return a WouldBlock io::Error (#65) 2017-12-06 10:32:58 -06:00
Thomas de Zeeuw
cf793d4053 Derive debug on public structs (#62)
* Derive Debug on all public structs

* Enable a warning about missing debug implementations on public struct
2017-12-06 10:19:21 -06:00
Alex Crichton
108e1a2c1a Blanket rename Core to Reactor
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'
2017-12-05 09:02:07 -08:00
Alex Crichton
46062794aa Tweak the PollEvented::deregister signature
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.
2017-12-05 08:54:48 -08:00
Alex Crichton
2e58422890 Add TcpListener::accept_std as a method
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`.
2017-12-05 08:48:17 -08:00
Alex Crichton
e86fc4917a Change need_read and need_write to return an error
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.
2017-12-05 08:43:01 -08:00
Alex Crichton
8fcce957cd Rename networking constructors with _std
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.
2017-12-05 08:24:26 -08:00
Alex Crichton
259996d805 Remove NEXT_LOOP_ID
This is no longer needed now that the public-facing `CoreId` has been removed
2017-12-05 08:19:47 -08:00
Alex Crichton
329bca15a6 Remove TcpListener::pending_accept field
No need for oneshot shenanigans as now we'll always have the `Handle` available
to us regardless of what thread we're on to associate a new socket
2017-12-05 08:17:08 -08:00
Alex Crichton
7c768fc046 Remove the Remote type
The `Handle` type is now `Send` and `Sync` so the `Remote` type no longer needs
to exist.
2017-12-05 08:15:26 -08:00
Thomas de Zeeuw
c801584d24 Doc improvements (#46)
* 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.
2017-12-05 09:55:25 -06:00
Thomas de Zeeuw
0b54557796 Remove unused code (#44)
* remove unused #[macro_use] and #[allow(unused_macros)]

* remove unused FnBox trait

* remove unused temporary variable

* remove Evented trait requirement to implement Debug
2017-12-01 15:34:03 -06:00
dethoter
31f8cb9467 Remove Core:id. (#41) 2017-11-21 10:18:11 -08:00
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
9c16d47632 Merge remote-tracking branch 'core/master' into new-crate 2017-11-06 23:30:10 -08:00
Carl Lerche
a402b1ca1e
Run CI on Travis (#31)
Mio should be providing the compatibility layer so there is no need to
run CI on OS X as well as Linux.

Benches are currently being skipped as the Tokio reform work progresses.
2017-11-06 23:08:14 -08:00
Alex Crichton
1fe55b2b55 Don't unwrap accepted connections
Helps avoid spurious errors when testing.

Closes #277
2017-11-06 08:23:11 -08:00
Alex Crichton
6cca729f40
Merge pull request #30 from seamusabshere/patch-1
s/serde/tokio/ in README license section
2017-11-02 16:26:46 -04:00
Seamus Abshere
2ab2affe69
s/serde/tokio/ 2017-11-02 16:01:42 -04:00
Carl Lerche
8c838a2709
Merge pull request #20 from tokio-rs/remove-scheduler
Remove executor from reactor.
2017-11-01 07:38:27 -07: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
Carl Lerche
b23a997cb8 Remove deprecated code.
This commit removes code that was deprecated in tokio-core master.
2017-10-30 16:37:15 -07:00
Carl Lerche
36aaaa1520 Rename crate to tokio 2017-10-30 16:37:00 -07:00
Alex Crichton
25f30c91c4 Clarify wording of license information in README.
This text historically was copied verbatim from rust-lang/rust's own README [1]
with the intention of licensing projects the same as rustc's own license, namely
a dual MIT/Apache-2.0 license. The clause about "various BSD-like licenses"
isn't actually correct for almost all projects other than rust-lang/rust and
the wording around "both" was slightly ambiguous.

This commit updates the wording to match more precisely what's in the
standard library [2], namely clarifying that there aren't any BSD-like licenses
in this repository and that the source is licensable under either license, at
your own discretion.

[1]: f0fe716dbc (license)
[2]: f0fe716dbc/src/libstd/lib.rs (L5-L9)
2017-10-30 14:17:01 -07:00
Alex Crichton
0c5c5dfafe
Merge pull request #271 from cramertj/simplify-udp
Simplify UdpSocket futures
2017-10-27 22:36:14 -04:00
Taylor Cramer
3588f4d6ad Simplify UdpSocket futures 2017-10-27 10:10:55 -07:00
Alex Crichton
ca8104ad69
Merge pull request #272 from cramertj/must-use
Set Future types as must_use
2017-10-27 12:19:21 -04:00
Alex Crichton
39173f8830 Merge pull request #270 from cramertj/fix-warnings
Fix warnings
2017-10-27 11:36:38 -04:00
Taylor Cramer
7624061021 Set Sink types as must_use 2017-10-25 18:03:31 -07:00
Taylor Cramer
bd9a07f3ad Set Stream types as must_use 2017-10-25 18:02:14 -07:00
Taylor Cramer
b4fa47bd09 Set Future types as must_use 2017-10-25 17:57:25 -07:00
Taylor Cramer
6b8ad4ff99 Fix warnings 2017-10-25 17:27:24 -07:00
Alex Crichton
01198532c1 Merge pull request #263 from casey/timeout-debug
Derive Debug for Timeout and TimeoutToken
2017-10-10 13:59:02 -04:00
Casey Rodarmor
e10de1e94e Derive Debug for Timeout and TimeoutToken 2017-10-09 20:16:38 -07:00
Alex Crichton
335c3e73a4 Fix UDP test 2017-10-05 19:57:36 -07:00
Alex Crichton
1c88b8f336 Bump to 0.1.10 2017-10-05 10:47:57 -07:00
Alex Crichton
84916f66fd Take &SocketAddr in connect 2017-10-05 10:47:57 -07:00
Alex Crichton
259c7a0884 Make poll_at private again
Unsure that we'll want to continue to expose this, stick to being conservative
for now.
2017-10-05 10:46:51 -07:00
Alex Crichton
25760609fa Avoid 0-length IoVec instances
These are unsound on Windows (unfortunately) and will soon be disallowed due to
carllerche/iovec#5
2017-10-05 10:41:05 -07:00
Alex Crichton
0868b97832 Add a tinydb example sharing state
This example is intended to showcase sharing state between all connected clients
on a server, for example a key/value store (in-memory database)

Closes #257
2017-09-23 12:22:34 -07:00
Alex Crichton
fbd0a9e5f1 Merge pull request #258 from alex/patch-1
Fixed docs for Timeout::new and new_at
2017-09-22 11:54:03 -05:00
Alex Gaynor
24dd856cfd Fixed docs for Timeout::new and new_at
They no longer return futures, they return io::Result.
2017-09-22 11:01:34 -04:00
Alex Crichton
e33155edb1 Merge pull request #255 from mathstuf/doc-typos
docs: fix some typos
2017-09-14 15:36:20 -05:00
Ben Boeckel
de33e02c01 docs: fix some typos 2017-09-14 16:19:45 -04:00
Alex Crichton
317c11552c Merge pull request #254 from alexcrichton/poll-at
Add {Interval,Timeout}::poll_at
2017-09-13 20:43:48 -05:00
Alex Crichton
fb05eb34af Merge pull request #253 from alexcrichton/perf
Conditionally call `consume_queue` on messages
2017-09-13 16:33:26 -05:00