Commit Graph
2465 Commits
Author SHA1 Message Date
John-John Tedro 2c5dc83019 cargo: path dependencies for all tokio things (#3764) 2021-05-08 12:54:30 +02:00
sb64 6b9bdd5ca2 chore: fix CI for Rust 1.52 (#3758) 2021-05-06 22:26:27 +02:00
Stefan d4075a4457 io: wake pending writers on DuplexStream close (#3756) 2021-05-06 18:30:39 +02:00
Stefan Sydow 177522cd43 benchmark: add file reading benchmarks (#3013) 2021-05-05 21:49:00 +02:00
Alice Ryhl 7ac341b526 task: update documentation on block_in_place (#3753) 2021-05-05 21:44:02 +02:00
Taiki Endo c4b6b130f3 chore: bump nightly to nightly-2021-04-25 (#3754) 2021-05-05 17:39:17 +02:00
Simon Lindholm 6845a93cbf sync: preserve permit state in notify_waiters (#3660) 2021-05-05 15:20:24 +02:00
Russell Cohen 8ef39dfb22 tokio-test: add assert_elapsed macro (#3728) 2021-05-05 12:09:28 +02:00
MGlolenstine 541b0c3af2 process: updated example (#3748) 2021-05-05 11:51:05 +02:00
Kai Mast 55c5d12451 util: require full feature in tokio-util tests (#3636) 2021-05-05 18:21:25 +09:00
Chế Vũ Gia Hy a945ce0996 stream: implement Error and Display for BroadcastStreamRecvError (#3745) 2021-05-05 11:15:42 +02:00
Russell Cohen 14bb2f624f io: add write_all_buf to AsyncWriteExt (#3737) 2021-05-01 20:54:38 +02:00
Marco Ieni a08ce0d3e0 ci: check docs of private items (#3715) 2021-04-30 13:25:50 +02:00
Arthur Silva 078e317c0b tokio: update CHANGELOG.md (#3735) 2021-04-30 00:26:28 +02:00
kamulos ce9697f2a2 doc: fix missing backtick in select doc (#3732) 2021-04-27 22:23:03 +09:00
Alice Ryhl 73466f4b6c task: update JoinHandle panic message (#3727) 2021-04-25 09:03:14 +02:00
Sunjay Varma 0ba1e3c3e1 sync: add a MutexGuard::map method that returns a MappedMutexGuard (#2472) 2021-04-23 17:26:02 +02:00
Nylonicious 1e2f893da2 chore: fix some clippy lints (#3720) 2021-04-22 13:33:42 +02:00
Carl Lerche 2b9b558108 time: prevent time::advance from going too far (#3712)
Previously, `time::advance` would set the mocked clock forward the
requested amount, then yield. However, if there was no work ready to
perform immediately, this would result in advancing to the next expiring
sleep.

Now, `time::advance(...)` will unblock at the requested time. The
difference between `time::advance(...)` and `time::sleep(...)` is a bit
fuzzy. The main difference is `time::sleep(...)` operates on the current
task and `time::advance(...)` operates at the runtime level.

Fixes #3710
2021-04-21 15:23:35 -07:00
Eliza Weisman d6da67b2e6 sync: add mpsc::Sender::{reserve_owned, try_reserve_owned} (#3704)
* sync: add `mpsc::Sender::{reserve_owned, try_reserve_owned}`

## Motivation

The `mpsc::Sender::reserve` method currently returns a permit that borrows
from the `Sender`. It would be nice to have a version of it that returns
an owned permit.

## Solution

This branch adds an `OwnedPermit` type and `Sender::{reserve_owned,
try_reserve_owned}` methods. Unlike the comparable methods on
`Semaphore`, these methods do *not* require an `Arc<Sender>` as the
receiver; this is because the sender internally reference counts the
channel and is already cheap to clone. Requiring an `Arc` would simply
add an unnecessary second layer of reference counting, which is not
ideal; instead, the documentation encourages the user to clone the
sender prior to calling `reserve_owned` when necessary.

Since these methods take the `Sender` by value, they also have the ability
to _return_ the `Sender` from a successful `OwnedPermit::send`. This
allows them to be used without additional clones. Essentially, this is a
very simple type-level encoding of the sender's state, with the
transitions
```
      ┌──────┐
 ┌───►│Sender├───┐
 │    └──────┘   │
send          reserve
 │ ┌───────────┐ │
 └─┤OwnedPermit│◄┘
   └───────────┘
```

Additionally, I added an `OwnedPermit::release`, which returns the
`Sender` and releases the permit *without* sending a message.

Closes #3688 

Signed-off-by: Eliza Weisman <[email protected]>
2021-04-15 12:55:57 -07:00
madjack c8a6bb0b90 time: add getter for Interval's period (#3705) 2021-04-15 14:21:52 +02:00
Evan Cameron 9eeec039f2 util: make UdpFramed take Borrow<UdpSocket> (#3451) 2021-04-14 20:16:23 +02:00
William Manley 39706b198c fs: try doing a non-blocking read before punting to the threadpool (#3518) 2021-04-14 15:44:49 +02:00
baoyachi. Aka Rust Hairy crabs cab4a592ac chore: update version in README.md (#3698) 2021-04-13 16:17:14 +09:00
Alice Ryhl a5ee2f0d3d chore: prepare Tokio v1.5.0 (#3695) tokio-1.5.0 2021-04-12 21:24:47 +02:00
Alice Ryhl 917aad684b chore: prepare tokio-util 0.6.6 (#3696) tokio-util-0.6.6 2021-04-12 21:23:20 +02:00
Alice Ryhl e366cf9b3e chore: upgrade loom to 0.5.0 (#3697) 2021-04-12 20:28:48 +02:00
Alice Ryhl 3a02d34d3a sync: document that Semaphore is fair (#3693) 2021-04-12 15:46:42 +02:00
conblem adad8fc3cd io: add a copy_bidirectional utility (#3572) 2021-04-12 14:18:45 +02:00
David Pedersen 08f1b67fcb sync: add mpsc::Sender::capacity (#3690)
Simply exposes the number of available permits of the semaphore.

This makes some kinds of bookkeeping easier without having to manually keep counts using atomics.

Fixes #2642
2021-04-12 09:23:03 +02:00
David Pedersen 28d6879897 macros: forward input arguments in #[tokio::test] (#3691)
Fixes #2388

Previously `#[tokio::test]` would error on functions that took
arguments. That meant other attribute macros couldn't do further
transformations on them. This changes that so arguments are forwarded as
is.

Whatever else might be included on the function is forwarded as well.
For example return type, generics, etc.

Worth noting that this is only for compatibility with other macros.
`#[test]`s that take arguments will still fail to compile.

A bit odd that [trybuild] tests don't fail `#[test]` functions with
arguments which is why the new tests are run with `t.pass(...)`. They do
actually fail if part of a real crate.

[trybuild]: https://crates.io/crates/trybuild
2021-04-11 20:39:05 +02:00
John-John Tedro 1a72b28f53 rt: fix panic in JoinHandle::abort() when called from other thread (#3672)
When aborting a task registered with a current-thread scheduler from off runtime, the tasks may not
be immediately unlinked from the runtime. Instead, send a message to the runtime, notifying it to
remove the aborted task.

Fixes #3662
2021-04-08 13:49:39 -07:00
Geoffry Song 1d5655272b runtime: use Park::Error: Debug for better panic messages (#3641) 2021-04-08 20:30:43 +02:00
Matthias Beyer 5513b6b825 time: change 300ms to 1s in documentation (#3685) 2021-04-08 11:04:27 +02:00
ty 787aca1826 net: implement IntoRawFd for TcpSocket (#3684) 2021-04-08 09:28:44 +02:00
Zahari Dichev e89c8981f1 sync: allow configuring RwLock max reads (#3644) 2021-04-07 20:44:29 +02:00
Eliza Weisman bf8c77bea1 util: add PollSemaphore::{add_permits, available_permits} (#3683)
## Motivation

The `tokio::sync::Semaphore` type provides a
[`Semaphore::available_permits` method][1] which returns the current
number of permits available on the semaphore.
`tokio_util::sync::PollSemaphore` [does not expose such a method][2]. It
is possible to use `PollSemaphore::into_inner` or
`PollSemaphore::clone_inner` to unwrap the inner semaphore, but this may
require cloning/dropping the semaphore's `Arc` which shouldn't be
necessary to access the permits.

## Solution

This commit adds `PollSemaphore::available_permits`. It also adds
`PollSemaphore::add_permits` and an `AsRef<Semaphore>` impl while
we're here.

[1]: https://docs.rs/tokio/1.4.0/tokio/sync/struct.Semaphore.html#method.available_permits
[2]: https://docs.rs/tokio-util/0.6.5/tokio_util/sync/struct.PollSemaphore.html#implementations

Closes #3682
2021-04-07 11:40:03 -07:00
Lucas Zanela 0074b963b8 doc: add features = "full" to readme (#3680) 2021-04-06 11:03:21 +02:00
David Pedersen eabb7ce61c io: add AsyncWriteExt::write_vectored (#3678)
Fixes #3676
2021-04-06 00:02:00 +02:00
David Pedersen 618d2bfc71 macros: various error message improvements (#3677)
Improves a few of the error messages for `#[tokio::main]` and `#[tokio::test]`.

Also adds a note to the docs about `start_paused` requiring the `test-util` feature which wasn't mentioned previously.
2021-04-05 22:40:42 +02:00
b-naber f6e4e85dfb sync: add OnceCell (#3591) 2021-04-05 22:03:57 +02:00
xd009642 f93bc9bad1 sync: don't panic in oneshot::try_recv (#3674) 2021-04-04 20:03:00 +02:00
Michael P. Jung b05b9a1788 sync: add Semaphore::is_closed (#3673) 2021-04-04 19:14:41 +02:00
Donough Liu b42f21ec3e doc: fix incorrect link in doc (#3670) 2021-04-01 15:24:29 +02:00
Nylonicious 8fc49dc522 chore: update years in all licenses (#3665) 2021-03-30 21:45:13 +02:00
Amos Wenger 9ec3393650 net: typo in socket.rs (#3663) 2021-03-30 20:44:54 +02:00
Simon Lindholm f7c181c2c4 sync: fix notifications getting dropped on receiver drop (#3652) 2021-03-30 09:18:07 +02:00
Alice Ryhl fee76ea7d5 chore: try to avoid noalias attributes on intrusive linked list (#3654) 2021-03-29 22:38:29 +02:00
CorinJG 1a80d6eee5 sync: improve doc on blocking mutex (#3645) 2021-03-27 13:26:10 +01:00
Taiki Endo 7384813979 chore: update proptest to 1 (#3653) 2021-03-27 19:34:11 +09:00