Commit Graph
2921 Commits
Author SHA1 Message Date
Max IndenandTaiki Endo 42b4c27b88 net: add take_error to TcpSocket and TcpStream (#4739)
Co-authored-by: Taiki Endo <[email protected]>
2022-06-03 19:50:52 +02:00
David KoloskiandDavid Koloski 0d4d3c34f1 sync: replace non-binding if let statements (#4735)
Found some `if let` statements that don't actually bind any variables.
This can make it somewhat confusing as to whether the pattern is binding
the value or being matched against. Switching to `matches!` and equality
comparisons allow these to be removed.

Co-authored-by: David Koloski <[email protected]>
2022-06-03 09:41:16 +02:00
Alice Ryhl 4941fbf7c4 tokio: add 1.18.x as LTS release (#4733) 2022-06-02 12:57:05 +02:00
David KoloskiandDavid Koloski cc6c2f40cb tokio: check page capacity before obtaining base pointer (#4731)
This doesn't cause any issues in practice because this is a private API
that is only used in ways that cannot trigger UB. Indexing into `slots`
is not sound until after we've asserted that the page is allocated,
since that aliases the first slot which may not be allocated. This PR
also switches to using `as_ptr` to obtain the base pointer for clarity.

Co-authored-by: David Koloski <[email protected]>
2022-06-01 21:18:06 +02:00
Aleksey Kladov 925314ba43 doc: clarify semantics of tasks outliving block_on (#4729) 2022-05-31 19:08:53 +00:00
Alice Ryhl f948cd7b33 chore: fix clippy warnings (#4727) 2022-05-31 20:26:32 +02:00
Name1e5s 83d0e7f8b3 runtime: add is_finished method for JoinHandle and AbortHandle (#4709) 2022-05-31 09:22:09 +00:00
Alice Ryhl 5fd1220c73 task: update return value of JoinSet::join_one (#4726) 2022-05-31 09:15:37 +02:00
Eliza Weisman 2bad98f879 task: add join_set::Builder for configuring JoinSet tasks (#4687) 2022-05-30 18:23:40 +02:00
Piotr Sarna 88e8c6239c task: add consume_budget for cooperative scheduling (#4498)
* task: add consume_budget for cooperative scheduling

For cpu-only computations that do not use any Tokio resources,
budgeting does not really kick in in order to yield and prevent
other tasks from starvation. The new mechanism - consume_budget,
performs a budget check, consumes a unit of it, and yields only
if the task exceeded the budget. That allows cpu-intenstive
computations to define points in the program which indicate that
some significant work was performed. It will yield only if the budget
is gone, which is a much better alternative to unconditional yielding,
which is a potentially heavy operation.

* tests: add a test case for task::consume_budget

The test case ensures that the task::consume_budget utility
actually burns budget and makes the task yield once the whole
budget is gone.
2022-05-30 09:15:54 +00:00
Alan Somers 6c0a9942ba metrics: correctly update atomics in IoDriverMetrics (#4725)
Updating an atomic variable with a load followed by a store is racy.  It
defeats the entire purpose of using atomic variables, and can result in
"lost" updates.  Instead, use fetch_add .
2022-05-30 11:14:56 +02:00
estk f6c0405084 sync: add resubscribe method to broadcast::Receiver (#4607) 2022-05-28 20:15:27 +00:00
Gus Wynn 05cbfae177 stream: add cancel-safety docs to StreamExt::next and try_next (#4715) 2022-05-27 10:28:29 +02:00
Eric Zhang 323b63fa04 time: fix example for MissedTickBehavior::Burst (#4713) 2022-05-22 21:22:03 +02:00
Rafael Bachmann 9f4959580f sync: add broadcast to list of channel types (#4712) 2022-05-22 16:46:34 +00:00
Name1e5s 50bd8ad17b chore: fix cargo audit warning by upgrading mockall (#4710) 2022-05-21 15:17:42 +02:00
Alice Ryhl 4675087090 sync: add Notified::enable (#4705) 2022-05-19 16:31:23 +00:00
Alice Ryhl a2112b47d3 chore: update macro output tests for rust 1.61.0 (#4706) 2022-05-19 15:55:11 +00:00
盏一 931a7773de io: refactor out usage of Weak in the io handle (#4656) 2022-05-19 10:24:27 +02:00
David Barsky 3fce06c2cc chore: add Netlify doc previews (#4699) 2022-05-19 09:30:06 +02:00
Aaron Turon 0b8a3c34a1 runtime: make global queue and event polling intervals configurable (#4671)
Adds knobs to the runtime builder to control the number of ticks
between polling the global task queue (fairness) and the event driver
(I/O prioritization).

Both varieties of scheduler already supported these intervals, but they
were defined by private constants. Some workloads benefit from
customizing these values.

Closes #4651
2022-05-18 11:23:53 +02:00
Alice Ryhl ddf2f5fdf6 rt: fix flaky wake_while_rt_is_dropping test (#4698) 2022-05-17 19:20:34 +02:00
Eliza Weisman 052355f064 task: add #[track_caller] to JoinSet/JoinMap (#4697)
## Motivation

Currently, the various spawning methods on `tokio::task::JoinSet` and
`tokio_util::task::JoinMap` lack `#[track_caller]` attributes, so the
`tracing` spans generated for tasks spawned on `JoinSet`s/`JoinMap`s
will have the `JoinSet` spawning method as their spawn location, rather
than the user code that called that method.

## Solution

This PR fixes that by...adding a bunch of `#[track_caller]` attributes.

## Future Work

In the future, we may also want to consider adding additional data to
the task span indicating that the task is spawned on a `JoinSet`...

Signed-off-by: Eliza Weisman <[email protected]>
2022-05-16 16:36:24 +00:00
Finomnis 454ac1c54f ci: enable ASAN in CI (#4696) 2022-05-16 16:57:03 +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) tokio-util-0.7.2 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 cdb132d333 Revert "chore: disable warnings in old CI (#4691)"
This reverts commit b24df49a9d so we can
merge the CHANGELOG changes in #4691 into master.
2022-05-14 20:59:52 +02:00
Alice Ryhl 2659adf5fe chore: prepare tokio-util 0.6.10 (#4691) tokio-util-0.6.10 2022-05-14 20:16:41 +02:00
Finomnis 0105d9971f sync: rewrite CancellationToken (#4652) 2022-05-14 20:16:36 +02:00
Alice Ryhl b24df49a9d chore: disable warnings in old CI (#4691) 2022-05-14 20:16:21 +02:00
Eliza Weisman b1557ea5b2 task: add Builder::{spawn_on, spawn_local_on, spawn_blocking_on} (#4683)
## Motivation

`task::JoinSet` currently has both `spawn`/`spawn_local` methods,
and `spawn_on`/`spawn_local_on` variants of these methods that take a
reference to a runtime `Handle` or to a `LocalSet`, and spawn tasks on
the provided runtime/`LocalSet`, rather than the current one. The
`task::Builder` type is _also_ an API type that can spawn tasks, but it
doesn't have `spawn_on` variants of its methods. It occurred to me that
it would be nice to have similar APIs on `task::Builder`.

## Solution

This branch adds `task::Builder::spawn_on`,
`task::Builder::spawn_local_on`, and `task::Builder::spawn_blocking_on`
methods, similar to those on `JoinSet`. In addition, I did some
refactoring of the internal spawning APIs --- there was a bit of
duplicated code that this PR reduces.

Signed-off-by: Eliza Weisman <[email protected]>
2022-05-14 10:44:47 -07:00
Alice Ryhl ce0e1152ad util: display JoinMap on docs.rs (#4689) 2022-05-14 18:55:26 +02:00
Alice Ryhl cf94ffc6fd windows: add features for winapi (#4663) 2022-05-14 16:44:44 +02:00
Sabrina Jewson f7346f04af util: simplify ReusableBoxFuture (#4675) 2022-05-13 23:39:13 +02:00
Finomnis addf5b5749 sync: rewrite CancellationToken (#4652) 2022-05-13 23:26:15 +02:00
Noah Kennedy 4ec6ba8b76 metrics: fix compilation with unstable, process, and rt (#4682)
Fixes #4681.
2022-05-11 19:31:37 +00:00
Sabrina Jewson 593b042f7b docs: mention that Clippy must be run with the MSRV (#4676)
## Motivation

In #4675 I learnt the hard way that Tokio uses Clippy on its MSRV. 

## Solution

Document this in the contributor's guide.
2022-05-10 17:53:43 +00:00
Alice Ryhl 71e18f7b75 Merge branch 'merge-1.18.2' into master 2022-05-08 23:37:56 +02:00
Alice Ryhl 7aa1566cde chore: prepare Tokio v1.18.2 tokio-1.18.2 2022-05-08 21:41:15 +02:00
Alice Ryhl 7c8e552f29 windows: add features for winapi (#4663) 2022-05-08 21:41:15 +02:00
Alice Ryhl 67074c3d44 windows: add features for winapi (#4663) 2022-05-08 20:14:28 +02:00
Alice Ryhl 938b7d6742 util: improve impl Send for ReusableBoxFuture docs (#4658) 2022-05-07 22:32:29 +02:00
Bruno 1872a425e2 macros: avoid starvation in join! and try_join! (#4624)
Fixes: #4612
2022-05-07 12:42:44 +02:00
Erick Tryzelaar c5ff797dcf udp: document and shrink some unsafe blocks (#4655)
This documents why it is safe to convert `bytes::UninitSlice` to `&mut
[MaybeUninit<u8>]`, and shrinks one of the unsafe blocks to make these
functions easier to audit.
2022-05-05 19:48:39 +00:00
Taiki Endo 2a305d2423 ci: update actions/checkout action to v3 (#4646) 2022-05-04 15:54:16 +02:00
Uwe Klotz c14566e9df watch: modify and send value conditionally (#4591)
Add a function that is more versatile than send_modify(). The result of
the passed closure indicates if the mutably borrowed value has actually
been modified or not. Receivers are only notified if the value has been
modified as indicated by the sender.

Signed-off-by: Uwe Klotz <[email protected]>
2022-05-03 06:57:10 +00:00
Alice Ryhl 148bea82ee tokio: prepare Tokio v1.18.1 (#4650) tokio-1.18.1 2022-05-02 17:07:27 +02:00
Alice Ryhl dc54aec1c7 metrics: use mocked AtomicU64 in IO metrics driver (#4649) 2022-05-02 13:32:59 +02:00
Taiki Endo fa665b91a8 macros: always emit return statement (#4636)
Fixes #4635
2022-04-28 07:53:40 +09:00