86 Commits

Author SHA1 Message Date
Roman
2e343f9e42 Reexport Encoder, Decoder, Framed* from tokio::codec (#499) 2018-08-14 11:18:54 -07:00
Sylwek
4ebaf18c27 Typo (#415) 2018-06-13 09:02:34 -07:00
Carl Lerche
ab07733d66
Deprecate executor re-exports (#412) 2018-06-12 14:41:12 -07:00
Bryan Burgers
f723d10087 Create tokio-codec (#360)
Create a new tokio-codec crate with many of the contents of
`tokio_io::codec`.
2018-06-04 20:36:06 -07:00
Michal 'vorner' Vaner
db9371126d Include a manually built runtime example (#306) 2018-05-29 14:44:28 -07:00
Jason Davies
1f5bb121e2 Fix typo in doc comment. (#361) 2018-05-14 11:10:25 -07:00
Julian Tescher
06b2c40222 Fix typos (#348) 2018-05-08 11:44:17 -07:00
Roman
5b677934fe Add example that prints each packet from tcp client (#301) 2018-04-10 13:08:55 -07:00
laizy
d8789cd379 fix panic in chat example (#279) 2018-04-02 09:00:40 -07:00
Denis
6bdfa159a7 Fix connect example for UDP (#241)
Close #241
2018-03-22 10:02:01 -07:00
Denis
16d3540ce9 Add UDP client example (send/recv_dgram) (#239) 2018-03-22 10:00:27 -07:00
Hiroaki Nakamura
d1046db735 Fix condition for updating the current date buffer (#230) 2018-03-15 09:29:55 -07:00
Gray Olson
95899e007d Update comment in udp-codec example (#222) 2018-03-12 10:39:32 -07:00
Tosil Velkov
2a1585157e Fix wrong file link in examples readme.md (#208) 2018-03-09 12:26:09 -08:00
Carl Lerche
fed4d72eff
Improve the chat example, making it more robust (#199)
This handles cases where clients send large amounts of data while on
localhost.

Closes #192
2018-03-08 13:38:52 -08:00
Carl Lerche
264fef60e3
Update readme (#196) 2018-03-07 22:28:01 -08:00
Carl Lerche
869615f1d2
Fix some comments in the examples. (#187)
The PR that updated the examples skipped some comments. This patch
updates thhe comments.
2018-03-06 12:00:49 -08:00
Carl Lerche
f1cb12e14f
Update examples to track latest Tokio changes (#180)
The exampes included in the repository have lagged behind the changes
made. Specifically, they do not use the new runtime construct.

This patch updates examples to use the latest features of Tokio.
2018-03-06 09:59:04 -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
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
a9da59882c
Fix example doc comment (#124)
Fixes #123
2018-02-08 09:09:02 -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
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
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
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
ae627db266 Change net::Incoming signature to match std. (#89)
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-30 15:01:34 -06:00
Carl Lerche
fd37fb0f17 Merge remote-tracking branch 'core/master' into new-crate 2018-01-26 14:50:41 -08:00
Roman
025f52aadc Fix UdpCodec::encode (#85)
*     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
2018-01-16 08:49:59 -08:00
Bastien Orivel
b395ccb6d9 Bump dependencies (#289) 2018-01-02 12:03:54 -06:00
Alex Crichton
4ef772b2db Remove Handle argument from I/O constructors (#61)
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-12 18:32:50 -06:00
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
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
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
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
Carl Lerche
9c16d47632 Merge remote-tracking branch 'core/master' into new-crate 2017-11-06 23:30:10 -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
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
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
Taylor Cramer
6b8ad4ff99 Fix warnings 2017-10-25 17:27:24 -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
8a43472b35 Add an example of compressing on a CPU pool 2017-09-11 14:41:15 -07:00
Alex Crichton
ecedea3404 Add a README for the examples 2017-09-11 13:31:08 -07:00
Alex Crichton
85257e19af Touch up a few examples 2017-09-11 08:43:11 -07:00
Alex Crichton
a611f6ec30 Add a UDP mode to the connect example 2017-09-11 08:33:09 -07:00
Alex Crichton
5e4cfdfab1 Recommend the connect example over nc 2017-09-11 08:07:38 -07:00
Alex Crichton
5e92b10f3f Add a "tiny" HTTP example
Hopefully being relatively illustrative in how a bare-bones non-production-ready
server can be spun up!
2017-09-10 21:45:23 -07:00
Alex Crichton
7b94cf307d Add a multithreaded echo server example 2017-09-10 08:54:35 -07:00