Commit Graph
3007 Commits
Author SHA1 Message Date
Clint Frederickson f5c1ff7599 chore: slight re-wording of unconstrained's module docs (#4928) 2022-08-21 14:15:18 -05:00
Noah Kennedy b67b8c1398 chore: stabilize JoinSet and AbortHandle (#4920)
Closes #4535.

This leaves the ID-related APIs unstable.
2022-08-19 17:16:11 +00:00
Linda_pp de81985762 docs: fix indent of tokio::sync::watch example code (#4922) 2022-08-18 09:12:58 -05:00
John DiSanti 4b1c4801b1 ci: upgrade to nightly-2022-07-26 and pin miri nightly (#4915) 2022-08-15 21:09:47 +00:00
weegee b3c7c9846b sync: add mpsc::Sender::max_capacity method (#4904) 2022-08-14 15:52:33 +00:00
John DiSanti d416b1d1d6 ci: upgrade nightly to nightly-2022-07-25 (#4903)
Upgrade the nightly to a version that works with all of miri,
cargo-hack, minimal-versions, and cargo-check-external-types.

This is a prerequisite for #4902.
2022-08-12 16:12:09 +00:00
Alice Ryhl 6e7a630243 docs: add changelog links to readme (#4907) 2022-08-12 15:57:53 +02:00
Alice Ryhl 16427f98c1 docs: link to GitHub discussions on "new issue" page (#4906) 2022-08-12 10:49:50 +00:00
Alice Ryhl 50b8ee99b7 ci: fix new error output from rustc 1.63.0 (#4905) 2022-08-12 08:57:30 +00:00
Alice Ryhl bdbb0ece10 task: add cancel safety docs to JoinHandle (#4901) 2022-08-11 11:17:03 +00:00
Sebastian Pütz 53e127205b sync: remove unused lifetime on SemaphorePermit impl (#4896) 2022-08-11 12:12:36 +02:00
Sebastian Pütz cd0ff7fbfe fs: change panic to error in File::start_seek (#4897) 2022-08-11 09:39:43 +00:00
Ivan Petkov d48c4370ce signal: don't register write interest on signal pipe (#4898) 2022-08-10 18:53:01 -07:00
Hayden Stainsby 9d9488db67 sync: remove broadcast channel slot level closed flag (#4867)
The broadcast channel allows multiple senders to send messages to
multiple receivers, where each receiver receives messages starting from
when it subscribes. After all senders are dropped, the receivers will
continue to receive all waiting messages in the buffer and then receive
a `Closed` error.

To mark that a channel has closed, it stores two closed flags, one on
the channel level and another in the buffer slot *after* the last used
slot (this may also be the earliest entry being kept for lagged
receivers, see #2425).

However, we don't need both closed flags, keeping the channel level
closed flag is sufficient.

Without the slot level closed flag, each receiver receives each message
until it is up to date and for that receiver the channel is empty. Then,
the actual return message is chosen depending on the channel level
closed flag; if the channel is NOT closed, then `Empty` is returned, if
the channel is closed then `Closed` is returned instead.

With the modified logic, there is no longer a need to append a closed
token to the internal buffer (by setting the slot level closed flag on
the next slot). This fixes the off by one error described in #4814,
which caused a receiver which was created after the channel was already
closed to get `Empty` from `try_recv` (or hang forever when calling
`recv`) instead of receiving `Closed`.

As a bonus, we save a single `bool` on each buffer slot.

Refs: #4814
2022-08-10 21:30:05 +02:00
Lioness100 53cf021b81 chore: fix word conjugations (#4894)
* chore: fix word tenses

* hyphenate
2022-08-10 11:50:25 -05:00
Tomio aea09478e1 io: fix typo in AsyncSeekExt::rewind docs (#4893) 2022-08-10 14:54:36 +00:00
Campbell He 2099d0bd87 net: add device and bind_device methods to TCP/UDP sockets (#4882) 2022-08-10 15:30:08 +02:00
Hayden Stainsby 255c1f95b7 doc: update clippy command in contribution guide (#4883)
The contribution guide describes the Tokio code of conduct and gives a
list of steps to follow when contributing in different ways. In the
guide to contributing a pull request, commands are listed to be run by
the contributor locally to help ensure that the PR will pass on CI.

The command to run clippy isn't the same as the one run on CI,
specifically the command doesn't check the tests. This commit changes
the command to match the one on CI, so that tests are checked by clippy
as well.
2022-08-09 23:46:21 +02:00
xxchan ff6fbc327d sync: add #[must_use] to lock guards (#4886) 2022-08-09 13:44:29 +02:00
199878e287 net: add tos and set_tos methods to TCP and UDP sockets (#4877)
Co-authored-by: Campbell He <[email protected]>
Co-authored-by: Taiki Endo <[email protected]>
2022-08-01 19:53:20 +02:00
Josh Soref 5ab6aaf3cd ci: scope workflows (#4857)
Signed-off-by: Josh Soref <[email protected]>
2022-07-30 13:55:53 +02:00
b-naber 1d75b57ad0 sync: implement Weak version of mpsc::Sender (#4595) 2022-07-27 15:36:52 +02:00
Alice RyhlandTaiki Endo b2ada60e70 wasm: use build script to detect wasm (#4865)
Co-authored-by: Taiki Endo <[email protected]>
2022-07-26 11:26:54 +00:00
Alice Ryhl 0dc62da21b chore: use target_family wasm instead of target_arch wasm32 (#4864) 2022-07-26 07:47:39 +00:00
Noah KennedyandCarl Lerche 28ce4eeab2 io: reduce syscalls in poll_read (#4840)
As the [epoll documentation points out](https://man7.org/linux/man-pages/man7/epoll.7.html), a read that only partially fills a buffer is sufficient to show that the socket buffer has been drained.

We can take advantage of this by clearing readiness in this case, which seems to significantly improve performance under certain conditions.

Co-authored-by: Carl Lerche <[email protected]>
2022-07-26 05:52:30 +00:00
Alice Ryhl ffff9e65fd chore: fix version detection for addr_of! (#4863) 2022-07-25 13:46:38 +00:00
Alice Ryhl 0906351daf Merge 'master' and 'tokio-1.20.1' 2022-07-25 14:21:40 +02:00
Alice Ryhl c0746b6a30 chore: prepare Tokio v1.20.1 (#4861) tokio-1.20.1 2022-07-25 14:21:00 +02:00
Alice Ryhl b673eae342 chore: fix version detection in build script (#4860) 2022-07-25 14:14:12 +02:00
Josh Soref f3e340a35b chore: fix spelling mistakes (#4858)
Signed-off-by: Josh Soref <[email protected]>
2022-07-25 07:26:01 +00:00
Ivan Petkov 94a7eaed51 Revert "tests: alter integration tests for stdio to not use a handrolled cat implementation (#4803)" (#4854)
This reverts commit d8cad13fd9.
2022-07-23 16:27:35 -07:00
Hayden Stainsby 62593be261 doc: remove incorrect panic section for Builder::worker_threads (#4849)
The documentation for the runtime `Builder::worker_threads` function
incorrectly stated that it would panic if used when constructing a
`current_thread` runtime. In truth, the call to the function has no
effect.

Since adding the described panic to the code could cause new panics in
existing code using tokio, the documentation has been modified to
describe the existing behavior.

Refs: #4773
2022-07-23 19:44:00 +02:00
Ivan Petkov 1578575db8 process: use blocking threadpool for child stdio I/O (#4824) 2022-07-23 10:40:04 -07:00
Hayden Stainsby 8c482a5d62 io: add track_caller caller to no-rt io driver (#4852)
This change adds a case that was missing from the original PR, #4793.

The `io::driver::Handle::current` function was only covered by
`#[track_caller]` in the case that the `rt` feature  is enabled, however
it was missing in the case that the `rt` feture isn't enabled (in which
case a panic would be more common).

This particular case cannot be tested in the tokio tests as they always
run with all features enabled.

Refs: #4413
2022-07-21 15:25:42 +00:00
Hayden Stainsby 5288e1e144 task: add track_caller to public APIs (#4848)
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 public APIs in the task
module of the tokio crate where the documentation describes how the
function may panic due to incorrect context or inputs.

In cases where `#[track_caller]` does not work, it has been left out.
For example, it currently does not work on async functions, blocks, or
closures. So any call stack that passes through one of these before
reaching the actual panic is not able to show the calling site outside
of tokio as the panic location.

The following functions have call stacks that pass through closures:
* `task::block_in_place`
* `task::local::spawn_local`

Tests are included to cover each potentially panicking function.

The following functions already had `#[track_caller]` applied everywhere
it was needed and only tests have been added:
* `task::spawn`
* `task::LocalKey::sync_scope`

Refs: #4413
2022-07-20 23:17:41 +02:00
Alice Ryhl 56be5286ee ci: update required ci steps (#4846) 2022-07-20 14:05:23 +02:00
dwattttt 21900bd42b net: add security flags to named pipe ServerOptions (#4845) 2022-07-20 11:13:39 +00:00
Alice Ryhl 228d4fce99 runtime: move owned field to Trailer (#4843) 2022-07-19 20:28:20 +02:00
Hayden Stainsby cbdba8bd32 net: add track_caller to public APIs (#4805)
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 net APIs
in the main tokio crate where the documentation describes how the
function may panic due to incorrect context or inputs.  Not all panic
cases can have #[track_caller] applied fully as the callstack passes
through a closure which isn't yet supported by the annotation (e.g. net
functions called from outside a tokio runtime).

Additionally, the documentation was updated to indicate additional cases
in which the public net functions may panic (the same as the io
functions).

Tests are included to cover each potentially panicking function.

Refs: #4413
2022-07-18 20:57:45 +00:00
Alice Ryhl 6f048ca954 tokio: avoid temporary references in linked_list::Link impls (#4841) 2022-07-18 22:47:17 +02:00
Arnav Singh 922fc91408 task: propagate attributes on task-locals (#4837) 2022-07-14 11:32:28 +02:00
Noah Kennedy 5cf22e48c5 chore: allow miri to use latest nightly once again (#4833)
This reverts [#4825], as miri seems to be working again on the latest nightly.

I had originally thought it was this issue with rustup which was to blame, but this seems to be wrong: https://github.com/rust-lang/rustup/issues/3031

[#4825]: https://github.com/tokio-rs/tokio/pull/4825
2022-07-13 11:35:28 -05:00
gftea 14fca343d5 task: add LocalSet::enter (#4736) (#4765) 2022-07-13 18:10:09 +02:00
Colin Walters 8e20cfb9ef task: expand on cancellation of spawn_blocking (#4811)
I was looking at these docs again and I was thinking the
"cannot be cancelled" is misleading; let's talk about approaches
to do so.
2022-07-13 16:41:13 +02:00
Alice Ryhl d7b074eca3 Merge branch 'tokio-1.20.x' into 'master' 2022-07-13 08:48:27 +02:00
Ivan Petkov 3b6c74a40a Make task::Builder::spawn* methods fallible (#4823) 2022-07-12 15:56:33 -07:00
Noah Kennedy b343767725 chore: prepare Tokio v1.20.0 (#4830) tokio-1.20.0 2022-07-12 22:03:44 +00:00
Eric Zhang de686b5355 runtime: fix typo in shutdown_background docs (#4829) 2022-07-12 20:51:28 +00:00
Richard Zak 6d3f92dddc wasm: initial support for wasm32-wasi target (#4716)
This adds initial, unstable, support for the wasm32-wasi target. Not all of Tokio's
features are supported yet as WASI's non-blocking APIs are still limited.

Refs: tokio-rs/tokio#4827
2022-07-12 13:20:26 -07:00
Noah Kennedy be620e913d chore: fix ci by hard-coding nightly version for miri (#4825)
It would seem that the latest nightly is having issues, so I went with the one from yesterday (2022-7-10).
2022-07-12 02:14:27 +00:00