Add mark_unchanged method to watch::Receiver#6252
Add mark_unchanged method to watch::Receiver#6252Darksonn merged 4 commits intotokio-rs:masterfrom PaulOlteanu:watch-mark-unchanged
mark_unchanged method to watch::Receiver#6252Conversation
|
I'm interested in feedback on how to make the doc clearer, I think it might be explained sort of awkwardly |
| /// After invoking this method [`has_changed()`](Self::has_changed) | ||
| /// *MAY* return `false` and [`changed()`](Self::changed) *MAY* not return | ||
| /// immediately. This is because a new value could be sent before | ||
| /// this method returns. |
There was a problem hiding this comment.
This is only the case if a value could be sent concurrently with this call. If there are no concurrent sends, then this does not apply.
There was a problem hiding this comment.
Yeah I'll explain that better. Should I also provide a warning that the value being marked as "seen" could change if used concurrently as well? e.g.
- receiver version is 2, shared version is 4.
mark_unchangedis called - another task sends a message so shared version becomes 6,
mark_unchangedsets receiver version to 6 - the caller intended to ignore the value associated with version 4 but instead skips 2 values
There was a problem hiding this comment.
I don't know how important the warning really is. It applies to anything that works with concurrency. You could say something along the lines of if another message is sent concurrently with the call to mark_unchanged, then you cannot predict whether the message or the mark_unchanged call comes first.
| /// After calling this method in a single-threaded context, a subsequent call to | ||
| /// [`has_changed()`](Self::has_changed) will return `false`, and a subsequent call | ||
| /// to [`changed()`](Self::changed) will yield. | ||
| /// | ||
| /// After calling this method in a multi-threaded context, subsequent | ||
| /// behaviour will vary depending on if a value is sent concurrently. | ||
| /// For example, a new value could be sent before this method returns | ||
| /// which would cause a call to [`changed`](Self::changed) to return immediately |
There was a problem hiding this comment.
Honestly, I think this is more confusing than it is useful. It's not clear what "single-threaded context" and "multi-threaded context" means. Does code running on a multi-threaded runtime necessarily imply that you are in a "multi-threaded context" according to this paragraph? No, but I anticipate being asked that question in the future. I would rather just take it out entirely.
There was a problem hiding this comment.
Yeah I'm cool with removing it
Bumps tokio from 1.35.1 to 1.36.0.
Release notes
Sourced from tokio's releases.
Tokio v1.36.0
1.36.0 (February 2nd, 2024)
Added
io: add tokio::io::Join (#6220)
io: implement AsyncWrite for Empty (#6235)
net: add support for anonymous unix pipes (#6127)
net: add UnixSocket (#6290)
net: expose keepalive option on TcpSocket (#6311)
sync: add {Receiver,UnboundedReceiver}::poll_recv_many (#6236)
sync: add Sender::{try_,}reserve_many (#6205)
sync: add watch::Receiver::mark_unchanged (#6252)
task: add JoinSet::try_join_next (#6280)
Changed
io: make copy cooperative (#6265)
io: make repeat and sink cooperative (#6254)
io: simplify check for empty slice (#6293)
process: use pidfd on Linux when available (#6152)
sync: use AtomicBool in broadcast channel future (#6298)
Documented
io: clarify clear_ready docs (#6304)
net: document that *Fd traits on TcpSocket are unix-only (#6294)
sync: document FIFO behavior of tokio::sync::Mutex (#6279)
chore: typographic improvements (#6262)
runtime: remove obsolete comment (#6303)
task: fix typo (#6261)
#6220: tokio-rs/tokio#6220
#6235: tokio-rs/tokio#6235
#6127: tokio-rs/tokio#6127
#6290: tokio-rs/tokio#6290
#6311: tokio-rs/tokio#6311
#6236: tokio-rs/tokio#6236
#6205: tokio-rs/tokio#6205
#6252: tokio-rs/tokio#6252
#6280: tokio-rs/tokio#6280
#6265: tokio-rs/tokio#6265
#6254: tokio-rs/tokio#6254
#6293: tokio-rs/tokio#6293
#6238: tokio-rs/tokio#6238
#6152: tokio-rs/tokio#6152
#6298: tokio-rs/tokio#6298
#6262: tokio-rs/tokio#6262
#6303: tokio-rs/tokio#6303
#6261: tokio-rs/tokio#6261
... (truncated)
Commits
eaf81ed chore: prepare Tokio v1.36.0 (#6312)
53f9e5a ci: make sure dictionary words are sorted and unique (#6316)
9077762 net: expose keepalive option on TcpSocket (#6311)
131e7b4 ci: add spellchecking (#6297)
e53b92a io: clarify clear_ready docs (#6304)
7536132 sync: use AtomicBool in broadcast channel future (#6298)
b6d0c90 macros: fix trait_method breaking change detection (#6308)
4846959 runtime: remove obsolete comment (#6303)
ec30383 net: add UnixSocket (#6290)
f80bbec io: simplify check for empty slice (#6293)
Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Motivation
Closes #6086
Solution
watch::Receivernow has a methodmark_unchangedthat just sets that receiver's version to the current version