274 Commits

Author SHA1 Message Date
cssivision
49abfdb2ac
util: fix typo in udp/frame.rs (#3154) 2020-11-20 15:06:14 +09:00
Taiki Endo
60366ca0fa
chore: update pin-project-lite to 0.2.0 (#3139) 2020-11-13 15:24:06 -08:00
Evan Cameron
47658a6da5
util: resurrect UdpFramed (#3044) 2020-11-06 16:59:15 +01:00
Akira Hayakawa
e309da0bee
util: remove stream feature flag from DelayQueue (#3087) 2020-11-03 09:20:24 +01:00
Naja Melan
4a7b7c52d1
util: copy paste error in documentation for Compat (#3088) 2020-11-02 13:25:51 +01:00
Dirkjan Ochtman
2b23aa7389
util: add back public poll_read_buf() function (#3079)
This was accidentally removed in #3064.
2020-11-01 10:22:22 +01:00
Carl Lerche
24ed874e81
chore: prepare tokio-util v0.5.0 release (#3078) 2020-10-30 11:26:15 -07:00
Dirkjan Ochtman
3965d91a5e
util: update to bytes 0.6 (#3071)
Copies the implementation of poll_read_buf() from tokio::io::util::read_buf.
2020-10-29 10:45:19 -07:00
Dirkjan Ochtman
a3ef4e4cf5
util: deduplicate implementations of poll_read_buf() (#3064) 2020-10-29 13:20:38 +01:00
Carl Lerche
d78655337a
Revert "util: upgrade tokio-util to bytes 0.6 (#3052)" (#3060)
This reverts commit fe2b997.

We are avoiding adding poll_read_buf to tokio itself for now. The patch is
reverted now in order to not block the v0.3.2 release (#3059).
2020-10-27 13:42:00 -07:00
Dirkjan Ochtman
fe2b997675
util: upgrade tokio-util to bytes 0.6 (#3052) 2020-10-27 09:30:29 +01:00
John-John Tedro
6d99e1c7de
util: prevent read buffer from being swapped during a read_poll (#2993) 2020-10-20 11:14:02 +02:00
John-John Tedro
8d17261a4b
util: add a poll_read_buf shim to tokio-util (#2972) 2020-10-19 11:06:06 +02:00
Carl Lerche
dc9742fbea
chore: post release Cargo.toml fixes (#2963) 2020-10-15 11:46:10 -07:00
Carl Lerche
12f1dffa2d
chore: prepare for v0.3.0 release (#2960) 2020-10-15 09:22:07 -07:00
Carl Lerche
00b6127f2e
rt: switch enter to an RAII guard (#2954) 2020-10-13 15:06:22 -07:00
Taiki Endo
c90681bd8e
rt: simplify rt-* features (#2949)
tokio:

    merge rt-core and rt-util as rt
    rename rt-threaded to rt-multi-thread

tokio-util:

    rename rt-core to rt

Closes #2942
2020-10-12 14:13:23 -07:00
Lucio Franco
8880222036
rt: Remove threaded_scheduler() and basic_scheduler() (#2876)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Co-authored-by: Carl Lerche <me@carllerche.com>
2020-10-12 13:44:54 -04:00
Juan Alvarez
0893841f31
time: move error types into time::error (#2938) 2020-10-12 10:21:44 -07:00
Lucio Franco
f8c91f2ead
io: Rename ReadBuf methods (#2945)
This changes `ReadBuf::add_filled` to `ReadBuf::advance` and
`ReadBuf::append` to `ReadBuf::put_slice`. This is just a
mechanical change.

Closes #2769
2020-10-12 12:41:40 -04:00
Juan Alvarez
60d81bbe10
time: rename Delay future to Sleep (#2932) 2020-10-08 20:35:12 -07:00
bdonlan
b704c53b9c
chore: Fix clippy lints (#2931)
Closes: #2929

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-10-08 17:14:39 -07:00
Zahari Dichev
43bd11bf2f
io: remove Poll from the AsyncSeek::start_seek return value (#2885) 2020-10-08 10:56:01 +02:00
Taiki Endo
d94ab62c54
util: fix a typo in sync/cancellation_token.rs (#2922) 2020-10-07 15:46:13 -07:00
greenwoodcm
fcdf9345bf
time: clean time driver (#2905)
* remove unnecessary wheel::Poll

the timer wheel uses the `wheel::Poll` struct as input when
advancing the timer to the next time step.  the `Poll` struct
contains an instant representing the time step to advance to
and also contains an optional and mutable reference to an
`Expiration` struct.  from what I can tell, the latter field
is only used in the context of polling the wheel and does not
need to be exposed outside of that method.  without the
expiration field the `Poll` struct is nothing more than a
wrapper around the instant being polled.  this change removes
the `Poll` struct and updates integration points accordingly.

* remove Stack trait in favor of concrete Stack implementation

* remove timer Registration struct
2020-10-06 12:48:01 -07:00
bdonlan
9730317e94
time: move DelayQueue to tokio-util (#2897)
This change is intended to do the minimum to unblock 0.3; as such, for now, we
duplicate the internal `time::wheel` structures in tokio-util, rather than trying
to refactor things at this stage.

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-10-05 14:25:04 -07:00
Juan Alvarez
53ccfc1fd6
time: introduce sleep and sleep_until functions (#2826) 2020-10-01 09:24:33 +02:00
Carl Lerche
4186b0aa38
io: remove poll_{read,write}_buf from traits (#2882)
These functions have object safety issues. It also has been decided to
avoid vectored operations on the I/O traits. A later PR will bring back
vectored operations on specific types that support them.

Refs: #2879, #2716
2020-09-24 17:26:03 -07:00
Sean McArthur
a0557840eb
io: use intrusive wait list for I/O driver (#2828)
This refactors I/O registration in a few ways:

- Cleans up the cached readiness in `PollEvented`. This cache used to
  be helpful when readiness was a linked list of `*mut Node`s in
  `Registration`. Previous refactors have turned `Registration` into just
  an `AtomicUsize` holding the current readiness, so the cache is just
  extra work and complexity. Gone.
- Polling the `Registration` for readiness now gives a `ReadyEvent`,
  which includes the driver tick. This event must be passed back into
  `clear_readiness`, so that the readiness is only cleared from `Registration`
  if the tick hasn't changed. Previously, it was possible to clear the
  readiness even though another thread had *just* polled the driver and
  found the socket ready again.
- Registration now also contains an `async fn readiness`, which stores
  wakers in an instrusive linked list. This allows an unbounded number
  of tasks to register for readiness (previously, only 1 per direction (read
  and write)). By using the intrusive linked list, there is no concern of
  leaking the storage of the wakers, since they are stored inside the `async fn`
  and released when the future is dropped.
- Registration retains a `poll_readiness(Direction)` method, to support
  `AsyncRead` and `AsyncWrite`. They aren't able to use `async fn`s, and
  so there are 2 reserved slots for those methods.
- IO types where it makes sense to have multiple tasks waiting on them
  now take advantage of this new `async fn readiness`, such as `UdpSocket`
  and `UnixDatagram`.

Additionally, this makes the `io-driver` "feature" internal-only (no longer
documented, not part of public API), and adds a second internal-only
feature, `io-readiness`, to group together linked list part of registration
that is only used by some of the IO types.

After a bit of discussion, changing stream-based transports (like
`TcpStream`) to have `async fn read(&self)` is punted, since that
is likely too easy of a footgun to activate.

Refs: #2779, #2728
2020-09-23 13:02:15 -07:00
Taiki Endo
111894fef9
util: remove Slice wrapper (#2847) 2020-09-19 20:40:20 +09:00
Alice Ryhl
4c4699be00
doc: fix some links (#2834) 2020-09-13 15:50:40 +02:00
Igor Aleksanov
ea79c95c67
util: implement Either type (#2821) 2020-09-08 09:14:08 +02:00
Alice Ryhl
37f405bd3b
io: move StreamReader and ReaderStream into tokio_util (#2788)
Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-09-08 09:12:32 +02:00
Lucio Franco
d600ab9a8f
rt: Refactor Runtime::block_on to take &self (#2782)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-08-27 20:05:48 -04:00
Blas Rodriguez Irizar
d9d909cb4c
util: Add TokioContext future (#2791)
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2020-08-27 11:33:43 -04:00
Carl Lerche
9d58b70151
sync: move CancellationToken to tokio-util (#2721)
* sync: move CancellationToken to tokio-util

The `CancellationToken` utility is only available with the
`tokio_unstable` flag. This was done as the API is not final, but it
adds friction for users.

This patch moves `CancellationToken` to tokio-util where it is generally
available. The tokio-util crate does not have any constraints on
breaking change releases.

* fix clippy

* clippy again
2020-08-23 17:45:52 +02:00
Sean McArthur
c393236dfd
io: change AsyncRead to use a ReadBuf (#2758)
Works towards #2716. Changes the argument to `AsyncRead::poll_read` to
take a `ReadBuf` struct that safely manages writes to uninitialized memory.
2020-08-13 20:15:01 -07:00
Carl Lerche
6ccefb77e2
chore: prepare for v0.3 breaking changes (#2747)
Bug fixes will be applied to the v0.2.x branch.
2020-08-07 20:27:53 -07:00
John Doneth
94b64cd70d
udp: Fix UdpFramed with regards to Decode (#1445) 2020-07-23 11:27:43 -04:00
Alice Ryhl
b094ee90e2
chore: fix new manual_non_exhaustive clippy lint (#2669)
Our minimum supported Rust version does not allow switching to `#[non_exhaustive]`.
2020-07-20 09:23:19 -07:00
xliiv
e70a1b6d64
docs: use intra-links in the docs (#2575) 2020-05-31 18:49:04 +02:00
Ondřej Hruška
4563699838
codec: add Framed::read_buffer_mut (#2546)
Adds a method to retrieve a mutable reference to the Framed stream's read buffer.
This makes it possible to e.g. externally clear the buffer to prevent the codec from
parsing stale data.
2020-05-20 21:45:03 +02:00
Geoff Shannon
b44ab27359
docs: improve discoverability of codec module (#2523) 2020-05-14 16:51:55 +02:00
Plecra
221f421464
codec: rewrite of codec::Framed (#2368)
Framed was designed to encapsulate both AsyncRead and AsyncWrite so
that it could wrap two-way connections. It used Fuse to manage the pinned
io object between the FramedWrite and FramedRead structs.

I replaced the Fuse struct by isolating the state used in reading and
writing, and making the code generic over that instead. This means
the FramedImpl struct now has a parameter for the state, and contains
the logic for both directions. The Framed* structs are now simply
wrappers around this type

Hopefully removing the `Pin` handling made things easier to
understand, too.
2020-05-12 13:47:38 +02:00
damienrg
43bbbf61a2
Remove relative link when possible and fix invalid links (#2423)
The link to tokio::main was relative to tokio_macros crate in the source
directory. This is why it worked in local build of documentation and not
in doc.rs.

Refs: #1473
2020-04-21 13:08:07 +02:00
Nikolai Vazquez
6f00d7158b
Link PRs in CHANGELOG files (#2383)
Allows for simply clicking on the PR number to view the corresponding
changes made.
2020-04-17 11:23:13 -04:00
xliiv
f39c15334e
docs: replace some html links with rustdoc paths (#2381)
Included changes
- all simple references like `<type>.<name>.html` for these types
    - enum
    - fn
    - struct
    - trait
    - type
- simple references for methods, like struct.DelayQueue.html#method.poll

Refs: #1473
2020-04-12 10:25:55 -07:00
Benjamin Halsted
215d7d4c5f
util: documentation example for LengthDelimitedCodec (#2339)
There is a gap in examples for Builder::num_skip() that shows how to
move past unused bytes between the length and payload.
2020-04-02 17:09:56 -04:00
Nikhil Benesch
5fd1b8f67c
util: Prepare 0.3.1 release (#2330) 2020-03-18 20:05:55 -04:00
Nikhil Benesch
9e58b37ad5
tokio-util: fix minimum supported version of tokio (#2326)
tokio-util uses tokio::stream::StreamExt, which was not introduced until
tokio v0.2.5. The current dependency specification is incorrect, and
breaks with cargo update -Z minimal-versions.
2020-03-18 18:18:53 -04:00