Commit Graph
1862 Commits
Author SHA1 Message Date
Alice Ryhl 894eb8b83f runtime: improve runtime and handle doc (#2440)
Refs: #2437
2020-04-24 21:05:10 +02:00
Alice Ryhl 3572ba5a7b task: update doc on spawn_blocking and block_in_place (#2436) 2020-04-24 10:16:46 -04:00
Dan Burkert d8139fef7a Add Handle::block_on method (#2437) 2020-04-24 15:25:48 +03:00
Alice Ryhl 9bcb50660e docs: make it easier to discover extension traits (#2434)
Refs: #2307
2020-04-23 15:11:49 -07:00
Alice Ryhl a3aab864d7 io: track rustfmt/clippy changes (#2431)
Refs: rust-lang/rustfmt#4140
2020-04-23 13:07:53 -07:00
Mikail Bagishov 236629d1be stream: fix panic in Merge and Chain size_hint (#2430) 2020-04-23 20:19:56 +02:00
Palash Ahuja f83f6388c4 task: link to lib.rs in spawn_blocking documentation (#2426) 2020-04-23 16:04:43 +02:00
Pythonidea 13974068f9 io: fix typo on AsyncWrite doc (#2427) 2020-04-22 19:18:48 +02:00
6349efd237 sync: improve mutex documentation (#2405)
Co-authored-by: Taiki Endo <[email protected]>
Co-authored-by: Alice Ryhl <[email protected]>
2020-04-21 20:36:13 +02:00
Geoffry Song 2da15b5f24 io: remove unsafe from ReadToString (#2384) 2020-04-21 19:41:41 +02:00
Taiki Endo 7e88b56be5 test: remove unnecessary unsafe code (#2424) 2020-04-22 02:34:55 +09:00
damienrg 43bbbf61a2 Remove relative link when possible and fix invalid links (#2423)
The link to tokio::main was relative to tokio_macros crate in the source
directory. This is why it worked in local build of documentation and not
in doc.rs.

Refs: #1473
2020-04-21 13:08:07 +02:00
Jon Gjengset 282b00cbe8 Be more principled about when blocking is ok (#2410)
This enables `block_in_place` to be used in more contexts. Specifically,
it allows you to block whenever you are off the tokio runtime (like if
you are not using tokio, are in a `spawn_blocking` closure, etc.), and
in the threaded scheduler's `block_on`. Blocking in `LocalSet` and the
basic scheduler's` block_on` is still disallowed.

Fixes #2327.
Fixes #2393.
2020-04-20 19:18:47 -04:00
Alice Ryhl 5a548044d7 sync: add owned semaphore permit (#2421) 2020-04-20 22:59:25 +02:00
Alice RyhlandEliza Weisman a748da1031 io: rewrite stdin documentation (#2420)
Co-authored-by: Eliza Weisman <[email protected]>
2020-04-20 20:44:08 +02:00
Gardner Vickers 6edc64afc7 task: Ensure the visibility modifier is propagated when constructing a task local (#2416) 2020-04-20 12:40:14 -04:00
Alice Ryhl 8f3a265972 net: introduce owned split on TcpStream (#2270) 2020-04-19 19:00:44 +02:00
Alice Ryhl 800574b4e0 doc: mention CPU-bound code lib.rs (#2414) 2020-04-18 18:46:51 -07:00
Lucio Franco 19a87e090e test: Add Future and Stream impl for Spawn. (#2412) 2020-04-17 15:37:59 -04:00
Nikolai Vazquez 6f00d7158b Link PRs in CHANGELOG files (#2383)
Allows for simply clicking on the PR number to view the corresponding
changes made.
2020-04-17 11:23:13 -04:00
Jon Gjengset 67c4cc0391 Support nested block_in_place (#2409) 2020-04-16 16:40:11 -04:00
Carl Lerche 8381dff39b chore: link mini-redis in examples (#2407) 2020-04-15 15:30:03 -07:00
xliiv 9553355c27 doc: fix a few broken links (#2400) 2020-04-13 17:25:28 +02:00
Taiki Endo 770d0ec452 ci: fix FreeBSD CI (#2403) 2020-04-13 14:41:42 +02:00
Alice Ryhl 5376f9181f chore: prepare to release 0.2.18 (#2399) tokio-0.2.18 2020-04-12 20:40:34 -07:00
Alice Ryhl 4fc2adae4f task: make LocalSet non-Send (#2398)
This does not count as a breaking change as it fixes a
regression and a soundness bug.
2020-04-12 14:55:37 -07:00
xliiv f39c15334e docs: replace some html links with rustdoc paths (#2381)
Included changes
- all simple references like `<type>.<name>.html` for these types
    - enum
    - fn
    - struct
    - trait
    - type
- simple references for methods, like struct.DelayQueue.html#method.poll

Refs: #1473
2020-04-12 10:25:55 -07:00
shuoandlishuo 060d22bd10 io: report error on zero-write in write_int (#2334)
* tokio-io: make write_i* same behavior as write_all when poll_write returns Ok(0)

Fixes: #2329

Co-authored-by: lishuo <[email protected]>
2020-04-12 16:05:03 +02:00
Nikita Baksalyar 8118f8f117 docs: fix incorrect documentation links & formatting (#2332)
The streams documentation referred to module-level 'split' doc which is no longer there
2020-04-12 15:59:37 +02:00
Max Inden 1e679748ec docs: remove duplicate "a listener" (#2395) 2020-04-12 15:41:14 +02:00
Eliza Weisman 3137c6f07d chore: prepare to release 0.2.17 (#2392)
# 0.2.17 (April 9, 2020)

### Fixes
- rt: bug in work-stealing queue (#2387) 

### Changes 
- rt: threadpool uses logical CPU count instead of physical by default
  (#2391)


Signed-off-by: Eliza Weisman <[email protected]>
tokio-0.2.17
2020-04-09 13:49:19 -07:00
Sean McArthur d294c992e7 Use logical CPUs instead of physical by default (#2391)
Some reasons to prefer logical count as the default:

- Chips reporting many logical CPUs vs physical, such as via
hyperthreading, probably know better than us about the workload the CPUs
can handle.
- The logical count (`num_cpus::get()`) takes into consideration
schedular affinity, and cgroups CPU quota, in case the user wants to
limit the amount of CPUs a process can use.

Closes #2269
2020-04-09 12:42:46 -07:00
Carl Lerche 58ba45a38c rt: fix bug in work-stealing queue (#2387)
Fixes a couple bugs in the work-stealing queue introduced as
part of #2315. First, the cursor needs to be able to represent more
values than the size of the buffer. This is to be able to track if
`tail` is ahead of `head` or if they are identical. This bug resulted in
the "overflow" path being taken before the buffer was full.

The second bug can happen when a queue is being stolen from concurrently
with stealing into. In this case, it is possible for buffer slots to be
overwritten before they are released by the stealer. This is harder to
happen in practice due to the first bug preventing the queue from
filling up 100%, but could still happen. It triggered an assertion in
`steal_into`. This bug slipped through due to a bug in loom not
correctly catching the case. The loom bug is fixed as part of
tokio-rs/loom#119.

Fixes: #2382
2020-04-09 11:35:16 -07:00
nasa de8326a5a4 doc: Sort methods on mpsc::Sender in doc (#2379) 2020-04-06 22:49:10 +02:00
Vojtech Kral d65bf3805b doc: add error explanation for UnboundedSender::send() (#2372) 2020-04-04 19:36:12 +02:00
Alice Ryhl 7c1bc460f7 test: add Send/Sync tests for all async fns (#2377)
Also updates Empty and Pending to be unconditionally Send and Sync.
2020-04-04 19:02:26 +02:00
Eliza Weisman d883ac0fa0 chore: prepare tokio 0.2.16 release
# 0.2.16 (April 3, 2020)

### Fixes

- sync: fix a regression where `Mutex`, `Semaphore`, and `RwLock` futures no
  longer implement `Sync` (#2375)
- fs: fix `fs::copy` not copying file permissions (#2354)

### Added

- time: added `deadline` method to `delay_queue::Expired` (#2300)
- io: added `StreamReader` (#2052) 

Signed-off-by: Eliza Weisman <[email protected]>
tokio-0.2.16
2020-04-03 17:00:42 -07:00
Eliza Weisman 1121a8eb23 sync: ensure Mutex, RwLock, and Semaphore futures are Send + Sync (#2375)
Previously, the `Mutex::lock`, `RwLock::{read, write}`, and
`Semaphore::acquire` futures in `tokio::sync` implemented `Send + Sync`
automatically. This was by virtue of being implemented using a `poll_fn`
that only closed over `Send + Sync` types. However, this broke in
PR #2325, which rewrote those types using the new `batch_semaphore`.
Now, they await an `Acquire` future, which contains a `Waiter`, which
internally contains an `UnsafeCell`, and thus does not implement `Sync`.

Since removing previously implemented traits breaks existing code, this
inadvertantly caused a breaking change. There were tests ensuring that
the `Mutex`, `RwLock`, and `Semaphore` types themselves were `Send +
Sync`, but no tests that the _futures they return_ implemented those
traits.

I've fixed this by adding an explicit impl of `Sync` for the
`batch_semaphore::Acquire` future. Since the `Waiter` type held by this
struct is only accessed when borrowed mutably, it is safe for it to
implement `Sync`.

Additionally, I've added to the bounds checks for the effected
`tokio::sync` types to ensure that returned futures continue to
implement `Send + Sync` in the future.
2020-04-03 15:45:29 -07:00
nasa 6fa40b6e20 doc: Fix readme link (#2370) 2020-04-03 09:00:18 -04:00
Alice Ryhl e10471dc3a io: Add StreamReader (#2052)
Allow conversion from a stream of chunks of bytes to an `AsyncRead`.
2020-04-02 14:18:52 -07:00
Alice Ryhl 0245515e4d examples: add comment about dependency gotcha (#2355) 2020-04-02 23:16:00 +02:00
MOZGIII 03cb3b6ca1 Expose time::deplay_queue::Expired::deadline (#2300)
* Expose time::deplay_queue::Expired::deadline

* Return by value
2020-04-02 17:11:17 -04:00
Kevin Leimkuhler 3eaa1885c3 fs: Copy file permissions (#2354)
Signed-off-by: Kevin Leimkuhler <[email protected]>
2020-04-02 17:10:44 -04:00
Benjamin Halsted cf4cbc142b test: Added read_error() and write_error() (#2337)
Enable testing of edge cases caused by io errors.
2020-04-02 17:10:12 -04:00
Benjamin Halsted 215d7d4c5f util: documentation example for LengthDelimitedCodec (#2339)
There is a gap in examples for Builder::num_skip() that shows how to
move past unused bytes between the length and payload.
2020-04-02 17:09:56 -04:00
Lucio Franco 2a8d917d2c chore: Prepare 0.2.15 release (#2365)
Signed-off-by: Lucio Franco <[email protected]>
tokio-0.2.15
2020-04-02 12:40:04 -04:00
Jon Gjengset 7fb1698e8d sync: Add disarm to mpsc::Sender (#2358)
Fixes #898.
2020-04-02 11:27:37 -04:00
Carl Lerche fa4fe9ef6f rt: fix queue regression (#2362)
The new queue uses `u8` to track offsets. Cursors are expected to wrap.
An operation was performed with `+` instead of `wrapping_add`. This was
not _obviously_ issue before as it is difficult to wrap a `usize` on
64bit platforms, but wrapping a `u8` is trivial.

The fix is to use `wrapping_add` instead of `+`. A new test is added
that catches the issue.

Fixes #2361
2020-04-02 07:52:02 -07:00
Carl Lerche f01136b5c0 chore: prepare tokio v0.2.14 release (#2356) tokio-0.2.14 2020-04-01 13:54:11 -07:00
Carl Lerche caa7e180e4 rt: cap fifo scheduler slot to avoid starvation (#2349)
The work-stealing scheduler includes an optimization where each worker
includes a single slot to store the **last** scheduled task. Tasks in
scheduler's LIFO slot are executed next. This speeds up and reduces
latency with message passing patterns.

Previously, this optimization was susceptible to starving other tasks in
certain cases. If two tasks ping-ping between each other without ever
yielding, the worker would never execute other tasks.

An early PR (#2160) introduced a form of pre-emption. Each task is
allocated a per-poll operation budget. Tokio resources will return ready
until the budget is depleted, at which point, Tokio resources will
always return `Pending`.

This patch leverages the operation budget to limit the LIFO scheduler
optimization. When executing tasks from the LIFO slot, the budget is
**not** reset. Once the budget goes to zero, the task in the LIFO slot
is pushed to the back of the queue.
2020-03-28 13:55:12 -07:00