Commit Graph
2253 Commits
Author SHA1 Message Date
Lucio FrancoandGitHub b99b00eb30 rt: change max_threads to max_blocking_threads (#3287)
Fixes #2802
2020-12-19 08:04:04 -08:00
Alice RyhlandGitHub d948ccedfc chore: fix stress test (#3297) 2020-12-19 12:11:10 +01:00
3ecaf9fd9a codec: write documentation for codec (#3283)
Co-authored-by: Lucio Franco <[email protected]>
2020-12-18 21:32:27 +01:00
Carl LercheandGitHub abd4c00255 time: enforce current_thread rt for time::pause (#3289)
Pausing time is a capability added to assist with testing Tokio code
dependent on time. Currently, the capability implicitly requires the
current_thread runtime.

This change enforces the requirement by panicking if called from a
multi-threaded runtime.
2020-12-17 15:37:08 -08:00
c5861ef62f docs: Add more comprehensive stream docs (#3286)
* docs: Add more comprehensive stream docs

* Apply suggestions from code review

Co-authored-by: Alice Ryhl <[email protected]>

* Fix doc tests

Co-authored-by: Alice Ryhl <[email protected]>
2020-12-17 11:46:09 -05:00
Lucio FrancoandGitHub 59e4b35f49 stream: Fix a few doc issues (#3285) 2020-12-17 10:35:49 -05:00
Carl LercheandGitHub d74d17307d time: remove Box from Sleep (#3278)
Removes the box from `Sleep`, taking advantage of intrusive wakers. The
`Sleep` future is now `!Unpin`.

Closes #3267
2020-12-16 21:51:34 -08:00
Lucio FrancoandGitHub 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
Zahari DichevandGitHub fcce78b33a sync: add Semaphore::close (#3065)
## Motivation
The need to expose `Semaphore::close` as explained in #3061. 

## Solution
Expose `Semaphore::close`

Signed-off-by: Zahari Dichev <[email protected]>
2020-12-15 10:22:45 -08:00
Carl LercheandGitHub 79d25b0a48 tracing: switch to unstable for 1.0. (#3266)
Enabling `tracing` integration now requires compiling with `--cfg
tokio_unstable`. Once `tracing-core` guarantees the same level of
stability as Tokio 1.0, unstable can be removed.

Closes #3258
2020-12-14 17:22:31 -08:00
Carl LercheandGitHub 3f29212cb7 fs: use cfgs on fns instead of OS ext traits (#3264)
Instead of using OS specific extension traits, OS specific methods are
moved onto the structs themselves and guarded with `cfg`. The API
documentation should highlight the function is platform specific.

Closes #2925
2020-12-14 09:29:10 -08:00
Joshua NelsonandGitHub 48961fac89 Document SinkExt and other futures traits on docs.rs (#3271)
These are extremely hard to find if you don't already know they exist.
2020-12-14 10:28:36 -05:00
Carl LercheandGitHub a7833e3007 sync: remove try_recv() from mpsc types (#3263)
The mpsc `try_recv()` functions have an issue where a sent message
happens-before a call to `try_recv()` but `try_recv()` returns `None`.
Fixing this is non-trivial, so the function is removed for 1.0. When the
bug is fixed, the function can be added back.

Closes #2020
2020-12-13 21:39:51 -08:00
Jacob O'TooleandGitHub 1f862d2e95 sync: add watch::Sender::borrow() (#3269) 2020-12-13 20:46:11 -08:00
Sylvain KerkourandGitHub 9149d7bfae docs: mention blocking thread timeout in src/lib.rs (#3253) 2020-12-13 16:24:16 +01:00
cssivisionandGitHub 4c55419453 net: add UnixStream readiness and non-blocking ops (#3246) 2020-12-13 16:21:11 +01:00
AldasandGitHub f26f444f42 doc: added tracing to the feature flags section (#3254) 2020-12-13 15:26:56 +01:00
cssivisionandGitHub be2cb7a5ce net: check for false-positives in TcpStream::ready doc test (#3255) 2020-12-13 15:24:59 +01:00
Sunjay VarmaandGitHub df20c162ae sync: add blocking_recv method to UnboundedReceiver, similar to Receiver::blocking_recv (#3262) 2020-12-12 08:47:35 -08:00
Alice RyhlandGitHub c1ec469ad2 util: add constructors to TokioContext (#3221) 2020-12-11 20:41:22 -08:00
Lucio FrancoandGitHub b01b2dacf2 net: update TcpStream::poll_peek to use ReadBuf (#3259)
Closes #2987
2020-12-11 20:40:24 -08:00
Evan CameronandGitHub 68717c7efa net: remove empty udp module (#3260) 2020-12-11 14:45:57 -05:00
Alice RyhlandGitHub 69e62ef89e sync: make TryAcquireError public (#3250)
The [`Semaphore::try_acquire`][1] method currently returns a private error type.

[1]: https://docs.rs/tokio/0.3/tokio/sync/struct.Semaphore.html#method.try_acquire
2020-12-10 19:56:05 -08:00
NyloniciousandGitHub 16c2e0983c net: Pass SocketAddr by value (#3125) 2020-12-10 14:58:27 -05:00
Yusuke TanakaandGitHub 4b1d76ec8f docs: fix typo in signal module documentation (#3249) 2020-12-10 08:11:45 -08:00
Clemens KozaandGitHub 9646b4bce3 toml: enable test-util feature for the playground (#3224) 2020-12-10 10:39:05 +01:00
f60860af7e watch: fix spurious wakeup (#3234)
Co-authored-by: @tijsvd
2020-12-10 09:46:01 +01:00
cssivisionandGitHub 2a30e13f38 net: expose poll_* methods on UnixDatagram (#3223) 2020-12-10 08:36:43 +01:00
NyloniciousandGitHub 52cd240053 task: add missing feature flags for task_local and spawn_blocking (#3237) 2020-12-09 23:49:28 +01:00
Carl LercheandGitHub 473ddaa277 chore: prepare for Tokio 1.0 work (#3238) 2020-12-09 09:42:05 -08:00
bdonlanandGitHub 9706ca92a8 time: Fix race condition in timer drop (#3229)
Dropping a timer on the millisecond that it was scheduled for, when it was on
the pending list, could result in a panic previously, as we did not record the
pending-list state in cached_when.

Hopefully fixes: ZcashFoundation/zebra#1452
2020-12-08 16:42:43 -08:00
Blas Rodriguez IrizarandGitHub fc7a4b3c6e chore: fix stress test (#3233) 2020-12-09 07:38:25 +09:00
Blas Rodriguez IrizarandGitHub e01391351b Add stress test (#3222)
Created a simple echo TCP server that on two different runtimes that is
called from a GitHub action using Valgrind to ensure that there are
no memory leaks.

Fixes: #3022
2020-12-07 21:12:22 -08:00
bdonlanandGitHub 57dffb9dfe rt: fix deadlock in shutdown (#3228)
Previously, the runtime shutdown logic would first-hand control over all cores
to a single thread, which would sequentially shut down all tasks on the core
and then wait for them to complete.

This could deadlock when one task is waiting for a later core's task to
complete. For example, in the newly added test, we have a `block_in_place` task
that is waiting for another task to be dropped. If the latter task adds its
core to the shutdown list later than the former, we end up waiting forever for
the `block_in_place` task to complete.

Additionally, there also was a bug wherein we'd attempt to park on the parker
after shutting it down which was fixed as part of the refactors above.

This change restructures the code to bring all tasks to a halt (and do any
parking needed) before we collapse to a single thread to avoid this deadlock.

There was also an issue in which canceled tasks would not unpark the
originating thread, due to what appears to be some sort of optimization gone
wrong. This has been fixed to be much more conservative in selecting when not
to unpark the source thread (this may be too conservative; please take a look
at the changes to `release()`).

Fixes: #2789
2020-12-07 20:55:02 -08:00
Carl LercheandGitHub 62023dffe5 sync: forward port 0.2 mpsc test (#3225)
Forward ports the test included in #3215. The mpsc sempahore has been
replaced in 0.3 and does not include the bug being fixed.
2020-12-07 11:24:15 -08:00
Fuyang LiuandGitHub 0707f4c192 net: add TcpStream::into_std (#3189) 2020-12-06 14:33:04 +01:00
Iban EguiaandGitHub 0dbba13984 deps: replace lazy_static with once_cell (#3187) 2020-12-04 10:23:13 +01:00
John-John TedroandGitHub a125ebd745 rt: fix panic in task abort when off rt (#3159)
A call to `JoinHandle::abort` releases a task. When called from outside of the runtime,
this panics due to the current implementation checking for a thread-local worker context.

This change makes accessing the thread-local context optional under release, by falling
back to remotely marking a task remotely as dropped. Behaving the same as if the core
was stolen by another worker.

Fixes #3157
2020-12-03 21:29:59 -08:00
Eliza WeismanandGitHub 00500d1b35 util: prepare v0.5.1 release (#3210)
### Added

- io: `poll_read_buf` util fn (#2972).
- io: `poll_write_buf` util fn with vectored write support (#3156).

Signed-off-by: Eliza Weisman <[email protected]>
tokio-util-0.5.1
2020-12-03 15:30:52 -08:00
Eliza WeismanandGitHub 647299866a util: add writev-aware poll_write_buf (#3156)
## Motivation

In Tokio 0.2, `AsyncRead` and `AsyncWrite` had `poll_write_buf` and
`poll_read_buf` methods for reading and writing to implementers of
`bytes` `Buf` and `BufMut` traits. In 0.3, these were removed, but
`poll_read_buf` was added as a free function in `tokio-util`. However,
there is currently no `poll_write_buf`.

Now that `AsyncWrite` has regained support for vectored writes in #3149,
there's a lot of potential benefit in having a `poll_write_buf` that
uses vectored writes when supported and non-vectored writes when not
supported, so that users don't have to reimplement this.

## Solution

This PR adds a `poll_write_buf` function to `tokio_util::io`, analogous
to the existing `poll_read_buf` function.

This function writes from a `Buf` to an `AsyncWrite`, advancing the
`Buf`'s internal cursor. In addition, when the `AsyncWrite` supports
vectored writes (i.e. its `is_write_vectored` method returns `true`),
it will use vectored IO.

I copied the documentation for this functions from the docs from Tokio
0.2's `AsyncWrite::poll_write_buf` , with some minor modifications as
appropriate.

Finally, I fixed a minor issue in the existing docs for `poll_read_buf`
and `read_buf`, and updated `tokio_util::codec` to use `poll_write_buf`.

Signed-off-by: Eliza Weisman <[email protected]>
2020-12-03 11:19:16 -08:00
Blas Rodriguez IrizarandGitHub a6051a61ec sync: make add_permits panic with usize::MAX >> 3 permits (#3188) 2020-12-02 22:58:28 +01:00
cssivisionandGitHub a8e0f0a919 example: add back udp-codec example (#3205) 2020-12-01 12:20:20 +09:00
Alan SomersandGitHub 7ae8135b62 process: fix the process_kill_on_drop.rs test on non-Linux systems (#3203)
"disown" is a bash builtin, not part of POSIX sh.
2020-12-01 10:20:49 +09:00
Alan SomersandGitHub 353b0544a0 ci: reenable CI on FreeBSD i686 (#3204)
It was temporarily disabled in 06c473e628
and never reenabled.
2020-12-01 10:20:18 +09:00
Alan SomersandGitHub 128495168d ci: switch FreeBSD CI environment to 12.2-RELEASE (#3202)
12.1 will be EoL in two months.
2020-12-01 10:19:54 +09:00
Carl LercheandGitHub 08548583b9 chore: prepare v0.3.5 release (#3201) tokio-0.3.5 2020-11-30 12:57:31 -08:00
HK416-is-all-you-needandGitHub 7707ba88ef io: add AsyncFd::with_interest (#3167)
Fixes #3072
2020-11-30 11:11:18 -08:00
Ivan ThamandGitHub 72d6346c0d macros: #[tokio::main] can be used on non-main (#3199) 2020-11-30 17:34:11 +01:00
Kyle KosicandGitHub a85fdb884d runtime: test for shutdown_timeout(0) (#3196) 2020-11-29 21:30:19 +01:00
Alice RyhlandGitHub c55d846f4b util: add rt to tokio-util full feature (#3194) 2020-11-29 09:48:31 +01:00