Commit Graph
2003 Commits
Author SHA1 Message Date
Nikolai VazquezandGitHub 827077409c fs: implement FromRawFd & FromRawHandle for File (#2792) 2020-08-28 09:53:51 +02:00
d600ab9a8f rt: Refactor Runtime::block_on to take &self (#2782)
Co-authored-by: Eliza Weisman <[email protected]>
2020-08-27 20:05:48 -04:00
d9d909cb4c util: Add TokioContext future (#2791)
Co-authored-by: Lucio Franco <[email protected]>
2020-08-27 11:33:43 -04:00
Blas Rodriguez IrizarandGitHub 262b19ae96 Docs delay queue (#2793) 2020-08-27 10:36:59 -04:00
xd009642andGitHub 347e18bc77 sync: add blocking_recv and blocking_send in mpsc (#2684)
Fixes: #2629
2020-08-26 21:39:06 +02:00
John-John TedroandGitHub 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 MillsandGitHub 0ccc09ac92 sync: fix typo in Notify documentation (#2794) 2020-08-26 20:26:43 +02:00
wspsxingandGitHub 4e12299826 runtime: add thread_name_fn method to runtime::Builder (#1921)
Fixes: #1907
2020-08-24 15:14:20 +02:00
Carl LercheandGitHub 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
caranatarandGitHub 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 IrizarandGitHub 138eef3526 test: implement Drop for Mock to panic w/ unconsumed data (#2704) 2020-08-20 15:48:27 -04:00
Sean McArthurandGitHub 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 LercheandGitHub 71da06097b chore: reformat some imports for consistency (#2768) 2020-08-13 08:10:00 -07:00
Carl LercheandGitHub 8feebab7cd io: rewrite slab to support compaction (#2757)
The I/O driver uses a slab to store per-resource state. Doing this
provides two benefits. First, allocating state is streamlined. Second,
resources may be safely indexed using a `usize` type. The `usize` is
used passed to the OS's selector when registering for receiving events.

The original slab implementation used a `Vec` backed by `RwLock`. This
primarily caused contention when reading state. This implementation also
only **grew** the slab capacity but never shrank. In #1625, the slab was
rewritten to use a lock-free strategy. The lock contention was removed
but this implementation was still grow-only.

This change adds the ability to release memory. Similar to the previous
implementation, it structures the slab to use a vector of pages. This
enables growing the slab without having to move any previous entries. It
also adds the ability to release pages. This is done by introducing a
lock when allocating/releasing slab entries. This does not impact
benchmarks, primarily due to the existing implementation not being
"done" and also having a lock around allocating and releasing.

A `Slab::compact()` function is added. Pages are iterated. When a page
is found with no slots in use, the page is freed. The `compact()`
function is called occasionally by the I/O driver.

Fixes #2505
2020-08-11 22:28:43 -07:00
Kruno Tomola FabroandGitHub 674985d9fb fs: add comment explaing File flush is a no-op (#2761)
Signed-off-by: Kruno Tomola Fabro <[email protected]>
2020-08-11 11:51:02 -07:00
Carl LercheandGitHub 77e6bb8d06 chore: bump MSRV to 1.45 (#2759)
As 0.3 is a breaking change, the minimum supported Rust version can be
changed.
2020-08-10 21:39:10 -07:00
Cameron TaggartandGitHub d8490c1626 io: use stderr in stderr documentation (#2746) 2020-08-09 09:37:55 +02:00
Blas Rodriguez IrizarandGitHub e9adac288e sync: typo in impl Semaphore (#2745) 2020-08-09 08:42:04 +02:00
Blas Rodriguez IrizarandGitHub 27bfe52bba sync: show correct permits in fmt::Debug (#2750)
Fixes: #2744
2020-08-08 13:41:55 -07:00
Carl LercheandGitHub 6ccefb77e2 chore: prepare for v0.3 breaking changes (#2747)
Bug fixes will be applied to the v0.2.x branch.
2020-08-07 20:27:53 -07:00
Blas Rodriguez IrizarandGitHub 1167c09ae8 process: document remote killing for Child (#2736)
* process: document remote killing for Child

Fixes: #2703
2020-08-05 00:59:10 +00:00
南浦月andGitHub 7276d47072 net: impl ToSocketAddrs for (String, u16) (#2724) 2020-08-01 15:27:14 +02:00
Max BrucknerandGitHub 9f0b6d3166 sync: suspectible -> susceptible (#2732) 2020-07-31 22:10:31 +02:00
Mikail BagishovandGitHub 8fda719845 sync: better Debug for Mutex (#2725) 2020-07-31 21:00:23 +02:00
Émile GrégoireandGitHub 646fbae765 rt: fix potential leak during runtime shutdown (#2649)
JoinHandle of threads created by the pool are now tracked and properly joined at
shutdown. If the thread does not return within the timeout, then it's not joined and
left to the OS for cleanup.

Also, break a cycle between wakers held by the timer and the runtime.

Fixes #2641, #2535
2020-07-28 20:43:19 -07:00
Kevin LeimkuhlerandGitHub 1562bb3144 add: Add UdpSocket::{try_send,try_send_to} methods (#1979) 2020-07-28 17:09:56 -07:00
Jon GjengsetandGitHub 0366a3e6d1 Reset coop budget when blocking in block_on (#2711)
Previously, we would fail to reset the coop budget in this case, making
it so that `coop::poll_proceed` would perpetually yield `Poll::Pending`
in nested executers even when run in `block_in_place`.

This is also a further improvement on #2645.
2020-07-28 19:58:33 -04:00
Alice RyhlandGitHub 03b68f4e75 io: rewrite read_to_end and read_to_string (#2560)
The new implementation changes the behavior such that set_len is called
after poll_read. The motivation of this change is that it makes it much
more obvious that a rouge panic won't give the caller access to a vector
containing exposed uninitialized memory. The new implementation also
makes sure to not zero memory twice.

Additionally, it makes the various implementations more consistent with
each other regarding the naming of variables, and whether we store how many
bytes we have read, or how many were in the container originally.

Fixes: #2544
2020-07-28 15:45:02 -07:00
084fcd7954 chore: update parking_lot dependency to 0.11.0 (#2676)
Co-authored-by: Jasper Hugo <[email protected]>
Co-authored-by: Alice Ryhl <[email protected]>
2020-07-28 15:43:08 -07:00
Alice RyhlandGitHub cc2c358d25 chore: document issue labels (#2708) 2020-07-28 15:41:43 -07:00
Jeb RosenandGitHub 51e7933c35 ci: add information to the rustfmt check, hinting at the necessary fix (#2673) 2020-07-28 13:30:33 -07:00
027351dd3a macros: silence unreachable_code warning in select! (#2678)
Solves #2665 by adding #[allow(unreachable_code)] inside a branch
matching arm.

Co-authored-by: Alice Ryhl <[email protected]>
2020-07-28 13:10:07 -07:00
Alice RyhlandGitHub ff6130da65 time: interval Stream impl requires stream feature (#2695)
Fixes: #1878
2020-07-26 21:23:06 +02:00
Alice RyhlandGitHub 018e345add time: fix incorrect argument name in doc (#2691) 2020-07-26 21:22:56 +02:00
Alice RyhlandGitHub e3e7cdeaff macros: document basic_scheduler option (#2697) 2020-07-26 09:51:56 -07:00
Felix GieseandGitHub 7f29acd964 time: fix resetting expired timers causing panics (#2587)
* Add Unit Test demonstrating the issue

This test demonstrates a panic that occurs when the user inserts an
item with an instant in the past, and then tries to reset the timeout
using the returned key

* Guard reset_at against removals of expired items

Trying to remove an already expired Timer Wheel entry (called by
DelayQueue.reset()) causes panics in some cases as described in (#2573)

This prevents this panic by removing the item from the expired queue and
not the wheel in these cases

Fixes: #2473
2020-07-26 09:40:29 +02:00
jean-airoldieandGitHub 2d97d5ad15 net: add try_recv/from & try_send/to to UnixDatagram (#1677)
This allows nonblocking sync send & recv operations on the socket.
2020-07-25 12:34:47 +02:00
Nikhil BeneschandGitHub d1744bf260 time: report correct error for timers that exceed max duration (#2023)
Closes #1953
2020-07-24 22:03:37 -07:00
Carl LercheandGitHub de7b8914a9 chore: add ci job that depends on all tests (#2690)
This makes it a bit easier to block a PR from landing without CI
passing.
2020-07-24 21:17:37 -07:00
Carl LercheandGitHub 9943acda81 chore: complete CI migration to Github Actions (#2680) 2020-07-24 16:28:24 -07:00
Alice RyhlandGitHub 4fca1974e9 net: ensure that unix sockets have both split and into_split (#2687)
The documentation build failed with errors such as

error: `[read]` public documentation for `take` links to a private item
    --> tokio/src/io/util/async_read_ext.rs:1078:9
     |
1078 | /         /// Creates an adaptor which reads at most `limit` bytes from it.
1079 | |         ///
1080 | |         /// This function returns a new instance of `AsyncRead` which will read
1081 | |         /// at most `limit` bytes, after which it will always return EOF
...    |
1103 | |         /// }
1104 | |         /// ```
     | |_______________^
     |
note: the lint level is defined here
    --> tokio/src/lib.rs:13:9
     |
13   | #![deny(intra_doc_link_resolution_failure)]
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: the link appears in this line:

             bytes read and future calls to [`read()`][read] may succeed.
2020-07-24 12:56:38 -07:00
Blas Rodriguez IrizarandGitHub 08872c55d1 doc: feature flags in README (#2682) 2020-07-24 20:51:34 +02:00
xd009642andGitHub 844d9c6acb rt: document how #[tokio::main] is expanded (#2683) 2020-07-24 08:32:15 -07:00
cssivisionandGitHub ff7125ec7b net: introduce split on UnixDatagram (#2557) 2020-07-23 22:03:47 -07:00
Taiki EndoandGitHub 7a60a0b362 io: always re-export std::io (#2606) 2020-07-23 22:00:27 -07:00
John DonethandGitHub 94b64cd70d udp: Fix UdpFramed with regards to Decode (#1445) 2020-07-23 11:27:43 -04:00
Alice RyhlandGitHub b5d2b0d05b doc: fix links to new website (#2674) 2020-07-22 20:35:02 -07:00
Sean McArthurandGitHub 0e090b7ae2 io: add io::duplex() as bidirectional reader/writer (#2661)
`duplex` returns a pair of connected `DuplexStream`s.

`DuplexStream` is a bidirectional type that can be used to simulate IO,
but over an in-process piece of memory.
2020-07-22 15:07:39 -07:00
Eliza WeismanandGitHub 21f726041c chore: prepare to release 0.2.22 (#2672)
# 0.2.22 (July 2!, 2020)

### Fixes
- docs: misc improvements (#2572, #2658, #2663, #2656, #2647, #2630, #2487, #2621,
  #2624, #2600, #2623, #2622, #2577, #2569, #2589, #2575, #2540, #2564, #2567,
  #2520, #2521, #2493)
- rt: allow calls to `block_on` inside calls to `block_in_place` that are
  themselves inside `block_on` (#2645)
- net: fix non-portable behavior when dropping `TcpStream` `OwnedWriteHalf` (#2597)
- io: improve stack usage by allocating large buffers on directly on the heap
  (#2634)
- io: fix unsound pin projection in `AsyncReadExt::read_buf` and
  `AsyncWriteExt::write_buf` (#2612)
- io: fix unnecessary zeroing for `AsyncRead` implementors (#2525)
- io: Fix `BufReader` not correctly forwarding `poll_write_buf` (#2654)
- io: fix panic in `AsyncReadExt::read_line` (#2541)

### Changes
- coop: returning `Poll::Pending` no longer decrements the task budget (#2549)

### Added
- io: little-endian variants of `AsyncReadExt` and `AsyncWriteExt` methods
  (#1915)
- task: add [`tracing`] instrumentation to spawned tasks (#2655)
- sync: allow unsized types in `Mutex` and `RwLock` (via `default` constructors)
  (#2615)
- net: add `ToSocketAddrs` implementation for `&[SocketAddr]` (#2604)
- fs: add `OpenOptionsExt` for `OpenOptions` (#2515)
- fs: add `DirBuilder` (#2524)

[`tracing`]: https://crates.io/crates/tracing

Signed-off-by: Eliza Weisman <[email protected]>
tokio-0.2.22
2020-07-21 17:52:16 -07:00
KornelandGitHub c344aac925 sync: support larger number of semaphore permits (#2607) 2020-07-21 16:51:42 -07:00