84 Commits

Author SHA1 Message Date
Alice Ryhl
74c6e6c683
chore: prepare tokio-util v0.7.8 (#5651) 2023-04-25 20:21:20 +02:00
Timmy Xiao
a7bb054414
tokio: update stream, util, test to 2021 edition (#5571) 2023-03-21 17:36:40 +00:00
Alice Ryhl
0c8e8248f8
tokio: bump MSRV to 1.56 (#5559) 2023-03-21 18:06:47 +01:00
Alice Ryhl
e629ad7c9a
chore: prepare tokio-util v0.7.7 (#5451) 2023-02-12 12:42:38 +01:00
Alice Ryhl
01bb1ecf4d
chore: prepare tokio-util v0.7.6 (#5447) 2023-02-10 10:48:36 +01:00
Alice Ryhl
36d2233579
chore: fix dependency on Tokio (#5445) 2023-02-10 10:13:37 +01:00
Alice Ryhl
74fb9e387a
chore: prepare tokio-util v0.7.5 (#5442) 2023-02-09 17:35:53 +01:00
Alice Ryhl
dfdb550cd4
chore: prepare tokio-util 0.7.4 (#4987) 2022-09-08 10:34:23 +02:00
Hayden Stainsby
ad412a9833
util: add track_caller to public APIs (#4785)
* util: add track_caller to public APIs

Functions that may panic can be annotated with `#[track_caller]` so that
in the event of a panic, the function where the user called the
panicking function is shown instead of the file and line within Tokio
source.

This change adds `#[track_caller]` to all the non-unstable public APIs in
tokio-util where the documentation describes how the function may panic
due to incorrect context or inputs.

In one place, an assert was added where the described behavior appeared
not to be implemented. The documentation for `DelayQueue::reserve`
states that the function will panic if the new capacity exceeds the
maximum number of entries the queue can contain. However, the function
didn't panic until a higher number caused by an allocation failure. This
is inconsistent with `DelayQueue::insert_at` which will panic if the
number of entries were to go over MAX_ENTRIES.

Tests are included to cover each potentially panicking function.

Refs: #4413

* fix tests on FreeBSD 32-bit (I hope)

Some tests were failing on FreeBSD 32-bit because the "times too far in
the future" for DelayQueue were also too far in the future for the OS.

Fixed by copying the MAX_DURATION value from where it's defined and
using it to create a duration that is just 1 more than the maximum. This
will start to break once we get close (within 2 and a bit years) of the
Epochalypse (19 Jan, 2038) - but a lot of other things are going to be
breaking on FreeBSD 32-bit by then anyway.
2022-06-27 12:31:31 +02:00
Alice Ryhl
14c77bc434
chore: prepare tokio-util 0.7.3 (#4744) 2022-06-04 22:04:02 +02:00
Alice Ryhl
fa06605e45 Merge 'tokio-util-0.7.x' into master 2022-05-15 10:09:29 +02:00
Alice Ryhl
038de36132 chore: prepare tokio-util 0.7.2 (#4690) 2022-05-14 21:06:13 +02:00
Alice Ryhl
42d5a9fcd4 Merge 'tokio-util-0.6.x' into 'tokio-util-0.7.x' 2022-05-14 21:03:16 +02:00
Alice Ryhl
2659adf5fe chore: prepare tokio-util 0.6.10 (#4691) 2022-05-14 20:16:41 +02:00
Finomnis
0105d9971f sync: rewrite CancellationToken (#4652) 2022-05-14 20:16:36 +02:00
Alice Ryhl
ce0e1152ad
util: display JoinMap on docs.rs (#4689) 2022-05-14 18:55:26 +02:00
Eliza Weisman
d456706528
util: implement JoinMap (#4640)
## Motivation

In many cases, it is desirable to spawn a set of tasks associated with
keys, with the ability to cancel them by key. As an example use case for
this sort of thing, see Tower's [`ReadyCache` type][1].

Now that PR #4530 adds a way of cancelling tasks in a
`tokio::task::JoinSet`, we can implement a map-like API based on the
same `IdleNotifiedSet` primitive.

## Solution

This PR adds an implementation of a `JoinMap` type to
`tokio_util::task`, using the `JoinSet` type from `tokio::task`, the
`AbortHandle` type added in #4530, and the new task IDs added in #4630.

Individual tasks can be aborted by key using the `JoinMap::abort`
method, and a set of tasks whose key match a given predicate can be
aborted using `JoinMap::abort_matching`.

When tasks complete, `JoinMap::join_one` returns their associated key
alongside the output from the spawned future, or the key and the
`JoinError` if the task did not complete successfully.

Overall, I think the way this works is pretty straightforward; much of
this PR is just API boilerplate to implement the union of applicable
APIs from `JoinSet` and `HashMap`. Unlike previous iterations on the
`JoinMap` API (e.g. #4538), this version is implemented entirely in
`tokio_util`, using only public APIs from the `tokio` crate. Currently,
the required `tokio` APIs are unstable, but implementing `JoinMap` in
`tokio-util` means we will never have to make stability commitments for
the `JoinMap` API itself.

[1]: https://github.com/tower-rs/tower/blob/master/tower/src/ready_cache/cache.rs

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-04-26 17:25:48 +00:00
Paolo Barbolini
f8a6cf49cd
tracing: don't require default tracing features (#4592) 2022-04-03 11:30:07 +02:00
Dirkjan Ochtman
a05135a4f8
chore: prepare tokio-util 0.7.1 release (#4521) 2022-03-28 14:34:11 +02:00
Gus Wynn
413c812ac8
util: switch tokio-util from log to tracing (#4539) 2022-02-26 12:47:04 +01:00
Dirkjan Ochtman
69f135ed60
util: bump tokio dependency to 1.6 to satisfy minimal versions (#4490) 2022-02-12 10:02:07 +01:00
Toby Lawrence
e7a0da60cd
chore: prepare tokio-util 0.7.0 (#4486) 2022-02-10 12:23:58 -05:00
Carl Lerche
49fff47111
chore: increase MSRV to 1.49. (#4457)
Rust 1.49 was released on December 31, 2020, which meets our MSRV policy
of a minimum of 6 months.
2022-01-31 13:26:12 -08:00
Mark Drobnak
257053e40b
util: add spawn_pinned (#3370) 2022-01-27 15:26:09 +01:00
b-naber
c800deaacc
util: add shrink_to_fit and compact methods to DelayQueue (#4170) 2022-01-09 12:41:30 +01:00
Toby Lawrence
4b6bb1d9a7
chore(util): start v0.7 release cycle (#4313)
* chore(util): start v0.7 release cycle

Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>
2021-12-10 13:16:17 -05:00
Taiki Endo
1a423b3322
chore: remove doc URL from Cargo.toml (#4251)
https://doc.rust-lang.org/cargo/reference/manifest.html#the-documentation-field

> If no URL is specified in the manifest file, crates.io will
> automatically link your crate to the corresponding docs.rs page.
2021-11-23 11:53:32 +01:00
Taiki Endo
cf3206842c
chore: bump MSRV to 1.46 (#4254) 2021-11-23 12:09:24 +09:00
Alice Ryhl
aa03622cf3
chore: prepare tokio-util 0.6.9 (#4199) 2021-10-29 18:34:23 +02:00
Colin Walters
2734fa9a85
util/io: add SyncIoBridge (#4146) 2021-10-22 18:46:29 +02:00
Toby Lawrence
01a6feb0dc
chore: prepare tokio-util v0.6.8 (#4087)
Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>
2021-09-03 10:57:27 -04:00
Alice Ryhl
deb1f98125
chore: prepare tokio-util v0.6.7 (#3784) 2021-05-14 18:22:08 +02:00
John-John Tedro
2c5dc83019
cargo: path dependencies for all tokio things (#3764) 2021-05-08 12:54:30 +02:00
Alice Ryhl
917aad684b
chore: prepare tokio-util 0.6.6 (#3696) 2021-04-12 21:23:20 +02:00
David Pedersen
b1310ad14d
chore: prepare tokio-util v0.6.5 (#3622) 2021-03-20 12:16:56 +01:00
Alice Ryhl
b08b5edb2c
chore: prepare tokio-util v0.6.4 (#3599) 2021-03-09 22:11:38 +01:00
Taiki Endo
36d7dab504
chore: remove html_root_url (#3489)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2021-02-18 14:11:39 -08:00
Alice Ryhl
60d88840f4
chore: prepare tokio-util v0.6.3 (#3488) 2021-01-31 12:39:22 +01:00
Alice Ryhl
ee1f0c473f
util: remove tokio-stream dependency from tokio-util (#3487) 2021-01-31 11:08:40 +01:00
Rob Ede
06d6adf4b7
util: use ReusableBoxFuture for PollSemaphore (#3463) 2021-01-30 10:57:04 +01:00
Alice Ryhl
198363f4f1
chore: prepare tokio-util 0.6.2 (#3453) 2021-01-21 11:46:50 +01:00
Alice Ryhl
27b2d681e6
util: add pollable Semaphore (#3444) 2021-01-20 09:53:31 +01:00
Taiki Endo
d37486dd06
util: remove path deps (#3413)
* util: remove path deps

* ci: run clippy with --all-features

* ci: run tests with --all-features on FreeBSD CI
2021-01-13 00:19:57 +09:00
Daiki Mizukami
ed667c669a
chore: prepare tokio-util v0.6.1 release (#3402) 2021-01-12 12:46:07 +01:00
Carl Lerche
a66017f049
chore: prepare Tokio 1.0 release (#3319) 2020-12-23 09:26:14 -08:00
Luke Steensen
a8dda19da4
chore: update to released bytes 1.0 (#3317) 2020-12-22 17:09:26 -08:00
Carl Lerche
2893359988
chore: update to bytes 1.0 git branch (#3301)
Updates the code base to track the `bytes` git branch. This is in
preparation for the 1.0 release.

Closes #3058
2020-12-19 15:57:16 -08:00
Carl Lerche
5e5f513542
chore: remove some left over stream feature code (#3300)
Removes the `stream` feature flag from `Cargo.toml` and removes the
`futures-core` dependency. Once `Stream` lands in `std`, a feature flag
is most likely not needed.
2020-12-19 14:15:00 -08:00
Alice Ryhl
3ecaf9fd9a
codec: write documentation for codec (#3283)
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2020-12-18 21:32:27 +01:00
Lucio Franco
8efa62013b
Move stream items into tokio-stream (#3277)
This change removes all references to `Stream` from
within the `tokio` crate and moves them into a new
`tokio-stream` crate. Most types have had their
`impl Stream` removed as well in-favor of their
inherent methods.

Closes #2870
2020-12-15 20:24:38 -08:00