summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/watch.rs
AgeCommit message (Collapse)Author
2020-12-10watch: fix spurious wakeup (#3234)Alice Ryhl
Co-authored-by: @tijsvd
2020-11-16sync: add `Notify::notify_waiters` (#3098)Zahari Dichev
This PR makes `Notify::notify_waiters` public. The method already exists, but it changes the way `notify_waiters`, is used. Previously in order for the consumer to register interest, in a notification triggered by `notify_waiters`, the `Notified` future had to be polled. This introduced friction when using the api as the future had to be pinned before polled. This change introduces a counter that tracks how many times `notified_waiters` has been called. Upon creation of the future the number of times is loaded. When first polled the future compares this number with the count state of the `Notify` type. This avoids the need for registering the waiter upfront. Fixes: #3066
2020-10-21sync: add is_closed method to watch sender (#2991)Nikolai Kuklin
2020-09-11sync: tweak `watch` API (#2814)Carl Lerche
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-01sync: watch channel breaking changes (#2806)Blas Rodriguez Irizar
Fixes: #2172
2020-07-20sync: remove misleading comment (#2666)nicolaiunrein
We are not returning the old value. I suppose this was once indented and this is a leftover.
2020-04-12docs: replace some html links with rustdoc paths (#2381)xliiv
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-01-29sync: reduce memory size of watch::Receiver (#2191)Sean McArthur
This reduces the `mem::size_of::<watch::Receiver>()` from 4 words to 2. - The `id` is now the pointer of the `Arc<WatchInner>`. - The `ver` is moved into the `WatchInner`.
2020-01-27docs: write sync mod API docs (#2175)Carl Lerche
Fixes #2171
2020-01-24docs: use third form in API docs (#2027)Oleg Nosov
2020-01-06chore: use just std instead of ::std in paths (#2049)Linus Färnstrand
2019-12-18stream: add `next` and `map` utility fn (#1962)Artem Vorotnikov
Introduces `StreamExt` trait. This trait will be used to add utility functions to make working with streams easier. This patch includes two functions: * `next`: a future returning the item in the stream. * `map`: transform each item in the stream.
2019-11-25doc: add more doc_cfg annotations (#1821)Carl Lerche
Also makes the `tokio::net::{tcp, udp, unix}` modules only for "utility" types. The primary types are in `tokio::net` directly.
2019-11-17sync: require `T: Clone` for watch channels. (#1783)Carl Lerche
There are limitations with `async/await` (no GAT) requiring the value to be cloned on receive. The `poll` based API is not currently exposed. This makes the `Clone` requirement explicit.
2019-11-15Limit `futures` dependency to `Stream` via feature flag (#1774)Carl Lerche
In an effort to reach API stability, the `tokio` crate is shedding its _public_ dependencies on crates that are either a) do not provide a stable (1.0+) release with longevity guarantees or b) match the `tokio` release cadence. Of course, implementing `std` traits fits the requirements. The on exception, for now, is the `Stream` trait found in `futures_core`. It is expected that this trait will not change much and be moved into `std. Since Tokio is not yet going reaching 1.0, I feel that it is acceptable to maintain a dependency on this trait given how foundational it is. Since the `Stream` implementation is optional, types that are logically streams provide `async fn next_*` functions to obtain the next value. Avoiding the `next()` name prevents fn conflicts with `StreamExt::next()`. Additionally, some misc cleanup is also done: - `tokio::io::io` -> `tokio::io::util`. - `delay` -> `delay_until`. - `Timeout::new` -> `timeout(...)`. - `signal::ctrl_c()` returns a future instead of a stream. - `{tcp,unix}::Incoming` is removed (due to lack of `Stream` trait). - `time::Throttle` is removed (due to lack of `Stream` trait). - Fix: `mpsc::UnboundedSender::send(&self)` (no more conflict with `Sink` fns).
2019-11-05fix clippy (#1737)Carl Lerche
2019-10-29sync: move into `tokio` crate (#1705)Carl Lerche
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The sync implementation is now provided by the main `tokio` crate. Functionality can be opted out of by using the various net related feature flags.