2140 Commits

Author SHA1 Message Date
Zahari Dichev
e7091fde78
sync: Remove readiness assertion in `watch::Receiver::changed() (#2839)
*In `watch::Receiver::changed` `Notified` was polled
for the first time to ensure the waiter is registered while
assuming that the first poll will always return `Pending`.
It is the case however that another instance of `Notified`
is dropped without receiving its notification, this "orphaned"
notification can be used to satisfy another waiter without
even registering it. This commit accounts for that scenario.
2020-09-22 08:12:57 -07:00
Carl Lerche
2348f678e6
Merge remote-tracking branch 'origin/v0.2.x' into merge-v0.2 2020-09-21 14:35:38 -07:00
Carl Lerche
93f8cb8df2
sync: fix missing notification during mpsc close (#2854)
When the mpsc channel receiver closes the channel, receiving should
return `None` once all in-progress sends have completed. When a sender
reserves capacity, this prevents the receiver from fully shutting down.
Previously, when the sender, after reserving capacity, dropped without
sending a message, the receiver was not notified. This results in
blocking the shutdown process until all sender handles drop.

This patch adds a receiver notification when the channel is both closed
and all outstanding sends have completed.
2020-09-21 14:35:09 -07:00
Carl Lerche
c0c7124a4b
sync: fix missing notification during mpsc close (#2854)
When the mpsc channel receiver closes the channel, receiving should
return `None` once all in-progress sends have completed. When a sender
reserves capacity, this prevents the receiver from fully shutting down.
Previously, when the sender, after reserving capacity, dropped without
sending a message, the receiver was not notified. This results in
blocking the shutdown process until all sender handles drop.

This patch adds a receiver notification when the channel is both closed
and all outstanding sends have completed.
2020-09-21 14:29:22 -07:00
Alice Ryhl
1ac10fa80a
ci: update miri flags (#2851)
* ci: update miri flags

* Update 2020-09-20 to 2020-09-21

Co-authored-by: Taiki Endo <te316e89@gmail.com>

Co-authored-by: Taiki Endo <te316e89@gmail.com>
2020-09-21 18:57:33 +02:00
Alice Ryhl
2b96b1773d
ci: update nightly and fix all sorts of new failures (#2852)
* ci: update miri flags

* ci: fix doc warnings

* doc: fix some links

Cherry-pick of 18ed761 from #2834

* ci: cherry-pick 00a2849

From: #2793

* ci: cherry-pick 6b61212

From: #2793

Co-authored-by: Blas Rodriguez Irizar <rodrigblas@gmail.com>
2020-09-21 18:57:27 +02:00
Taiki Endo
ba8680d667
io: fix doc-cfg on AsyncSeekExt (#2846) 2020-09-19 20:40:37 +09:00
Taiki Endo
111894fef9
util: remove Slice wrapper (#2847) 2020-09-19 20:40:20 +09:00
Taiki Endo
68f7eff39e
time: remove outdated todo comment (#2848) 2020-09-19 20:40:03 +09:00
Nylonicious
207320dbbb
process: fix some docs (#2843)
* fix docs for Command::status and output

Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-09-18 22:49:13 +00:00
Nylonicious
3fd043931e
sync: fix some doc typos (#2838)
Fixes #2781.
2020-09-17 08:03:38 +02:00
Alice Ryhl
4c4699be00
doc: fix some links (#2834) 2020-09-13 15:50:40 +02:00
Frank Steffahn
8d2e3bc575
sync: add const constructors to RwLock, Notify, and Semaphore (#2833)
* Add const constructors to `RwLock`, `Notify`, and `Semaphore`.

Referring to the types in `tokio::sync`.
Also add `const` to `new` for the remaining atomic integers in `src/loom` and `UnsafeCell`.

Builds upon previous work in #2790
Closes #2756
2020-09-12 22:58:58 +02:00
mental
20ef286553
sync: add const-constructors for some sync primitives (#2790)
Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-09-12 11:55:03 +02:00
Carl Lerche
2bc9a48152
sync: tweak watch API (#2814)
Decouples getting the latest `watch` value from receiving the change
notification. The `Receiver` async method becomes
`Receiver::changed()`. The latest value is obtained from
`Receiver::borrow()`.

The implementation is updated to use `Notify`. This requires adding
`Notify::notify_waiters`. This method is generally useful but is kept
private for now.
2020-09-11 15:14:45 -07:00
Max Heller
c5a9ede157
sync: write guard to read guard downgrading for sync::RwLock (#2733) 2020-09-11 22:00:04 +02:00
Zephyr Shannon
ce0af8f7a1
docs: more doc fixes (#2831)
Previous docs look like they were based on the docs for
`insert_at`. Changed names of variables referred to and the
explanation of when the value will be returned and under what
condition it will be immediately available to make sense for a
Duration argument instead of an Instant.
2020-09-11 12:44:33 -07:00
Zephyr Shannon
be7462e50f
sync: document mpsc::bounded minimum buffer size (#2808) 2020-09-09 22:28:28 +02:00
xd009642
1550dda5cf
stream: module level docs for tokio::stream (#2786) 2020-09-09 09:08:23 +02:00
John-John Tedro
cbb14a7bb9
sync: add JoinHandle::abort (#2474) 2020-09-08 20:52:57 -07:00
Blas Rodriguez Irizar
a0a356152e
sync: remove rt-core from blocking_{send,recv} (#2825) 2020-09-08 20:50:38 -07: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
Ivan Petkov
7c254eca44
process: make Child::kill async (#2823)
* This changes the `Child::kill` to be an async method which awaits the
  child after sending a kill signal. This avoids leaving zombie
  processes on Unix platforms if the caller forgets to await the child
  after the kill completes
* A `start_kill` method was also added on `Child` which only sends the
  kill signal to the child process. This allows for kill signals to be
  sent even outside of async contexts.
2020-09-08 06:03:25 +00:00
Blas Rodriguez Irizar
f4d6ed03d9
runtime: add custom keep_alive functionality (#2809)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Fixes: #2585
2020-09-07 21:32:34 +02:00
Juan Alvarez
38ec4845d1
sync: rename Notify::notify() -> notify_one() (#2822)
Closes: #2813
2020-09-07 20:56:15 +02:00
Ivan Petkov
842d5565bd
process: add Child::{wait,try_wait} (#2796)
* add Child::try_wait to mirror the std API
* replace Future impl on Child with `.wait()` method to bring our
  APIs closer to those in std and it allow us to
  internally fuse the future so that repeated calls to `wait` result in
  the same value (similar to std) without forcing the caller to fuse the
  outer future
* Also change `Child::id` to return an Option result to avoid
  allowing the caller to accidentally use the pid on Unix systems after
  the child has been reaped
* Also remove deprecated Child methods
2020-09-07 03:30:40 +00:00
George Malayil Philip
d74eabc7d7
runtime: mention on JoinHandle that the generic parameter is the return type (#2819) 2020-09-05 22:44:42 +02:00
Blas Rodriguez Irizar
6260ed907b
tokio: document missing timer panics (#2801)
Fixes: #2696
Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2020-09-05 20:33:42 +02:00
Zahari Dichev
048174012d
fs: remove File::seek (#2810)
Fixes: #1993
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
2020-09-05 20:32:20 +02:00
Igor Aleksanov
38cab93330
runtime: improve runtime vs #[tokio::main] doc (#2820) 2020-09-05 20:22:47 +02:00
Zahari Dichev
171cb57fa1
io: add ReadBuf::take (#2817)
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
2020-09-05 11:09:54 -07:00
mental
c9f5bc2915
util: add const fn support for internal LinkedList. (#2805) 2020-09-02 12:37:13 -07:00
Blas Rodriguez Irizar
5cdb6f8fd6
time: move throttle to StreamExt (#2752)
Ref: #2727
2020-09-02 11:52:31 +02:00
Blas Rodriguez Irizar
5a1a6dc90c
sync: watch channel breaking changes (#2806)
Fixes: #2172
2020-09-01 20:57:48 -07:00
Nikolai Vazquez
827077409c
fs: implement FromRawFd & FromRawHandle for File (#2792) 2020-08-28 09:53:51 +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
Blas Rodriguez Irizar
262b19ae96
Docs delay queue (#2793) 2020-08-27 10:36:59 -04:00
John-John Tedro
f0328f7810
sync: implement map methods of parking_lot fame (#2771)
* sync: Implement map methods of parking_lot fame

Generally, this mimics the way `MappedRwLock*Guard`s are implemented in
`parking_lot`. By storing a raw pointer in the guards themselves
referencing the mapped data and maintaining type invariants through
`PhantomData`. I didn't try to think too much about this, so if someone
has objections I'd love to hear them.

I've also dropped the internal use of `ReleasingPermit`, since it made
the guards unecessarily large. The number of permits that need to be
released are already known by the guards themselves, and is instead
governed directly in the relevant `Drop` impls.  This has the benefit of
making the guards as small as possible, for the non-mapped variants this
means a single reference is enough.

`fmt::Debug` impls have been adjusted to behave exactly like the
delegating impls in `parking_lot`. `fmt::Display` impls have been added
for all guard types which behave the same. This does change the format
of debug impls, for which I'm not sure if we provide any guarantees.
2020-08-27 08:23:38 +02:00
xd009642
347e18bc77
sync: add blocking_recv and blocking_send in mpsc (#2684)
Fixes: #2629
2020-08-26 21:39:06 +02:00
John-John Tedro
2e7e42bca7
sync: implement map methods of parking_lot fame (#2445)
Generally, this mimics the way `MappedRwLock*Guard`s are implemented in
`parking_lot`. By storing a raw pointer in the guards themselves
referencing the mapped data and maintaining type invariants through
`PhantomData`. I didn't try to think too much about this, so if someone
has objections I'd love to hear them.

I've also dropped the internal use of `ReleasingPermit`, since it made
the guards unecessarily large. The number of permits that need to be
released are already known by the guards themselves, and is instead
governed directly in the relevant `Drop` impls.  This has the benefit of
making the guards as small as possible, for the non-mapped variants this
means a single reference is enough.

`fmt::Debug` impls have been adjusted to behave exactly like the
delegating impls in `parking_lot`. `fmt::Display` impls have been added
for all guard types which behave the same. This does change the format
of debug impls, for which I'm not sure if we provide any guarantees.
2020-08-26 20:50:35 +02:00
James Mills
0ccc09ac92
sync: fix typo in Notify documentation (#2794) 2020-08-26 20:26:43 +02:00
wspsxing
4e12299826
runtime: add thread_name_fn method to runtime::Builder (#1921)
Fixes: #1907
2020-08-24 15:14:20 +02:00
Mikail Bagishov
30d4ec0a20
io: add ReaderStream (#2714) 2020-08-23 17:47:20 +02: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
caranatar
fde72bf047
net: Add examples to UnixDatagram (#2765)
* net: adding examples for UnixDatagram

Adding examples to documentation for UnixDatagram

* net: document named UnixDatagrams persistence

Add documentation to indicate that named UnixDatagrams 'leak'
socket files after execution.

* net: rustfmt issue in UnixDatagram

Fixing rustfmt issue in UnixDatagram

* net: adding examples for UnixDatagram

Fixes: #2686
Refs: #1679
Refs: #1111
2020-08-23 17:45:10 +02:00
Blas Rodriguez Irizar
138eef3526
test: implement Drop for Mock to panic w/ unconsumed data (#2704) 2020-08-20 15:48:27 -04: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
71da06097b
chore: reformat some imports for consistency (#2768) 2020-08-13 08:10:00 -07:00