2099 Commits

Author SHA1 Message Date
Lucio Franco
f8c91f2ead
io: Rename ReadBuf methods (#2945)
This changes `ReadBuf::add_filled` to `ReadBuf::advance` and
`ReadBuf::append` to `ReadBuf::put_slice`. This is just a
mechanical change.

Closes #2769
2020-10-12 12:41:40 -04:00
Zahari Dichev
b575082543
sync: change chan closed(&mut self) to closed(&self) (#2939) 2020-10-12 12:09:36 -04:00
Taiki Endo
c4f620cb30
chore: remove use of doc_alias feature (#2944) 2020-10-12 09:42:59 +02:00
Taiki Endo
b047f647b7
net: make UCred fields private (#2936) 2020-10-11 09:31:26 +02:00
Taiki Endo
2e05399f4b
sync: move broadcast error types into broadcast::error module (#2937)
Refs: #2928
2020-10-09 10:10:22 -07:00
Carl Lerche
afe535283c
fs: future proof File (#2930)
Changes inherent methods to take `&self` instead of `&mut self`. This
brings the API in line with `std`.

This patch is implemented by using a `tokio::sync::Mutex` to guard the
internal `File` state. This is not an ideal implementation strategy
doesn't make a big impact compared to having to dispatch operations to a
background thread followed by a blocking syscall.

In the future, the implementation can be improved as we explore async
file-system APIs provided by the operating-system (iocp / io_uring).

Closes #2927
2020-10-09 10:02:55 -07:00
Carl Lerche
ee597347c5
net: switch socket methods to &self (#2934)
Switches various socket methods from &mut self to &self. This uses the intrusive
waker infrastructure to handle multiple waiters.

Refs: #2928
2020-10-09 09:16:42 -07:00
Taiki Endo
41ac1ae2bc
io: make Seek and Copy private (#2935)
Refs: #2928
2020-10-09 08:33:14 -07:00
Juan Alvarez
60d81bbe10
time: rename Delay future to Sleep (#2932) 2020-10-08 20:35:12 -07:00
bdonlan
b704c53b9c
chore: Fix clippy lints (#2931)
Closes: #2929

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-10-08 17:14:39 -07:00
Carl Lerche
066965cd59
net: use &self with TcpListener::accept (#2919)
Uses the infrastructure added by #2828 to enable switching
`TcpListener::accept` to use `&self`.

This also switches `poll_accept` to use `&self`. While doing introduces
a hazard, `poll_*` style functions are considered low-level. Most users
will use the `async fn` variants which are more misuse-resistant.

TcpListener::incoming() is temporarily removed as it has the same
problem as `TcpSocket::by_ref()` and will be implemented later.
2020-10-08 12:12:56 -07:00
Taiki Endo
6259893094
fs: add os::windows::OpenOptionsExt (#2923) 2020-10-08 11:09:12 +02:00
Zahari Dichev
43bd11bf2f
io: remove Poll from the AsyncSeek::start_seek return value (#2885) 2020-10-08 10:56:01 +02:00
Taiki Endo
d94ab62c54
util: fix a typo in sync/cancellation_token.rs (#2922) 2020-10-07 15:46:13 -07:00
Carl Lerche
a9a59ea90e
net: add TcpSocket for configuring a socket (#2920)
This enables the caller to configure the socket and to explicitly bind
the socket before converting it to a `TcpStream` or `TcpListener`.

Closes: #2902
2020-10-07 13:02:29 -07:00
Taiki Endo
c248167173
fs: switch to our own DirEntryExt trait (#2921) 2020-10-08 02:30:25 +09:00
Evan Cameron
601a3ef93f
docs: more docs for UdpSocket (#2883) 2020-10-06 18:12:02 -07:00
greenwoodcm
fcdf9345bf
time: clean time driver (#2905)
* remove unnecessary wheel::Poll

the timer wheel uses the `wheel::Poll` struct as input when
advancing the timer to the next time step.  the `Poll` struct
contains an instant representing the time step to advance to
and also contains an optional and mutable reference to an
`Expiration` struct.  from what I can tell, the latter field
is only used in the context of polling the wheel and does not
need to be exposed outside of that method.  without the
expiration field the `Poll` struct is nothing more than a
wrapper around the instant being polled.  this change removes
the `Poll` struct and updates integration points accordingly.

* remove Stack trait in favor of concrete Stack implementation

* remove timer Registration struct
2020-10-06 12:48:01 -07:00
Ivan Petkov
4cf45c038b
process: add ProcessDriver to handle orphan reaping (#2907) 2020-10-06 17:30:16 +00:00
bdonlan
9730317e94
time: move DelayQueue to tokio-util (#2897)
This change is intended to do the minimum to unblock 0.3; as such, for now, we
duplicate the internal `time::wheel` structures in tokio-util, rather than trying
to refactor things at this stage.

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-10-05 14:25:04 -07:00
Taiki Endo
02311dcfa1
io, stream: assert !Unpin for ext trait futures (#2913) 2020-10-06 04:44:34 +09:00
Alice Ryhl
aa171f2aa9
stream: remove bytes from public API (#2908) 2020-10-05 10:33:15 -07:00
Taiki Endo
c23c1ecbcb
io, stream: make ext trait futures !Unpin (#2910)
Make these future `!Unpin` for compatibility with async trait methods.
2020-10-05 10:32:11 -07:00
Taiki Endo
561a71ad63
net: implement AsRawSocket on Windows (#2911) 2020-10-05 10:22:19 -07:00
Alice Ryhl
242ea01189
sync: broadcast channel API tweaks (#2898)
Removes deprecated APIs and makes some small breaking changes.
2020-10-05 09:30:48 -07:00
Mikail Bagishov
1684e1c809
io: optimize writing large buffers to windows stdio (#2888) 2020-10-05 16:07:46 +02:00
Taiki Endo
0ed4127d5c
fs: seal OpenOptionsExt and DirBuilderExt (#2909) 2020-10-05 00:47:35 +09:00
Carl Lerche
1e585ccb51
io: update to Mio 0.7 (#2893)
This also makes Mio an implementation detail, removing it from the
public API.

This is based on #1767.
2020-10-02 13:54:00 -07:00
Alice Ryhl
7ec6d88b21
chore: make #[doc(hidden)] apis private (#2901) 2020-10-01 21:13:28 -07:00
Alice Ryhl
13de30c53e
task: remove deprecated JoinError constructors (#2900) 2020-10-02 01:01:11 +03:00
Alice Ryhl
496e889917
Fix new clippy warning (#2899) 2020-10-02 00:59:48 +03:00
Juan Alvarez
53ccfc1fd6
time: introduce sleep and sleep_until functions (#2826) 2020-10-01 09:24:33 +02:00
Sean McArthur
971ed2c6df
Seal FromStream methods with an internal argument (#2894) 2020-09-29 07:41:20 -07:00
Matt Kennedy
dcb11118d2
test: fix spelling error in documentation (#2895)
Fixes: #2754
2020-09-29 13:23:11 +02:00
Linus Behrbohm
3403be5e2e
stream: add iter and iter_mut methods to StreamMap (#2890) 2020-09-29 10:07:22 +02:00
Sean McArthur
c6fc35aadf
Seal ToSocketAddrs methods with an internal argument (#2892)
Closes #2891
2020-09-28 14:43:41 -07:00
Mikail Bagishov
078d0a2ebc
sync: Add is_closed method to mpsc senders (#2726)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-09-28 11:37:28 -04:00
Mikail Bagishov
99d4061203
bench: fix unused_mut lint in benches (#2889) 2020-09-27 11:07:55 +02:00
Sean McArthur
dfdfd61372
Fix readiness future eagerly consuming entire socket readiness (#2887)
In the `readiness` future, before inserting a waiter into the list, the current socket readiness is eagerly checked. However, it would return as a `ReadyEvent` the entire socket readiness, instead of just the interest desired from `readiness(interest)`. This would result in the later call to `clear_readiness(event)` removing all of it.

Closes #2886
2020-09-25 16:34:40 -07:00
Zahari Dichev
55d932a21f
sync: add mpsc::Sender::closed future (#2840)
Adding closed future, makes it possible to select over closed and some other
work, so that the task is woken when the channel is closed and can proactively
cancel itself.

Added a mpsc::Sender::closed future that will become ready when the receiver
is closed.
2020-09-25 08:40:31 -07:00
Zahari Dichev
444660664b
chore: handle std Mutex poisoning in a shim (#2872)
As tokio does not rely on poisoning, we can
avoid always unwrapping when locking by handling
the `PoisonError` in the Mutex shim.

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
2020-09-25 08:38:13 -07:00
Carl Lerche
cf025ba45f
sync: support mpsc send with &self (#2861)
Updates the mpsc channel to use the intrusive waker based sempahore.
This enables using `Sender` with `&self`.

Instead of using `Sender::poll_ready` to ensure capacity and updating
the `Sender` state, `async fn Sender::reserve()` is added. This function
returns a `Permit` value representing the reserved capacity.

Fixes: #2637
Refs: #2718 (intrusive waiters)
2020-09-24 17:26:38 -07:00
Carl Lerche
4186b0aa38
io: remove poll_{read,write}_buf from traits (#2882)
These functions have object safety issues. It also has been decided to
avoid vectored operations on the I/O traits. A later PR will bring back
vectored operations on specific types that support them.

Refs: #2879, #2716
2020-09-24 17:26:03 -07:00
bdonlan
760ae89401
chore: Use IoSlice's Copy impl to clean up some repetitive code (#2875)
As we go into 0.3 we no longer need to support older versions of Rust where
IoSlice did not implement Copy and Clone, so we can more easily initialize the
IoSlice array in net::tcp::stream.

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-09-24 14:50:10 -07:00
Ivan Petkov
56acde069f
chore: remove internal io-driver cargo feature (#2881) 2020-09-24 21:36:42 +00:00
Ivan Petkov
ffa5bdb22d
chore: remove internal io-readiness cargo feature (#2878) 2020-09-24 20:14:39 +00:00
Ivan Petkov
a1d0681cd2
process: do not publicly turn on signal when enabled (#2871)
This change will still internally compile any `signal` resources
required when `process` is enabled on unix systems, but it will not
publicly turn on the cargo feature
2020-09-24 10:51:46 -07:00
Lucio Franco
4dfbdbff7e
rt: Allow concurrent Shell:block_on calls (#2868) 2020-09-24 13:31:49 -04:00
Taiki Endo
c29f13b7a5
docs: use #[doc(no_inline)] on re-exports (#2874) 2020-09-24 22:59:47 +09:00
Sean McArthur
a0557840eb
io: use intrusive wait list for I/O driver (#2828)
This refactors I/O registration in a few ways:

- Cleans up the cached readiness in `PollEvented`. This cache used to
  be helpful when readiness was a linked list of `*mut Node`s in
  `Registration`. Previous refactors have turned `Registration` into just
  an `AtomicUsize` holding the current readiness, so the cache is just
  extra work and complexity. Gone.
- Polling the `Registration` for readiness now gives a `ReadyEvent`,
  which includes the driver tick. This event must be passed back into
  `clear_readiness`, so that the readiness is only cleared from `Registration`
  if the tick hasn't changed. Previously, it was possible to clear the
  readiness even though another thread had *just* polled the driver and
  found the socket ready again.
- Registration now also contains an `async fn readiness`, which stores
  wakers in an instrusive linked list. This allows an unbounded number
  of tasks to register for readiness (previously, only 1 per direction (read
  and write)). By using the intrusive linked list, there is no concern of
  leaking the storage of the wakers, since they are stored inside the `async fn`
  and released when the future is dropped.
- Registration retains a `poll_readiness(Direction)` method, to support
  `AsyncRead` and `AsyncWrite`. They aren't able to use `async fn`s, and
  so there are 2 reserved slots for those methods.
- IO types where it makes sense to have multiple tasks waiting on them
  now take advantage of this new `async fn readiness`, such as `UdpSocket`
  and `UnixDatagram`.

Additionally, this makes the `io-driver` "feature" internal-only (no longer
documented, not part of public API), and adds a second internal-only
feature, `io-readiness`, to group together linked list part of registration
that is only used by some of the IO types.

After a bit of discussion, changing stream-based transports (like
`TcpStream`) to have `async fn read(&self)` is punted, since that
is likely too easy of a footgun to activate.

Refs: #2779, #2728
2020-09-23 13:02:15 -07:00