Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semaphore example for limiting access to a file #5939

Merged

Conversation

matildasmeds
Copy link
Contributor

To improve Semaphore examples, as called for in Issue #5933, here is a simple example for limiting access to a File resource.

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Aug 18, 2023
@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Aug 18, 2023
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

tokio/src/sync/semaphore.rs Outdated Show resolved Hide resolved
tokio/src/sync/semaphore.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good to me.

@Darksonn Darksonn merged commit bc26934 into tokio-rs:master Aug 20, 2023
71 checks passed
kodiakhq bot pushed a commit to pdylanross/fatigue that referenced this pull request Oct 10, 2023
Bumps tokio from 1.32.0 to 1.33.0.

Release notes
Sourced from tokio's releases.

Tokio v1.33.0
1.33.0 (October 9, 2023)
Fixed

io: mark Interest::add with #[must_use] (#6037)
runtime: fix cache line size for RISC-V (#5994)
sync: prevent lock poisoning in watch::Receiver::wait_for (#6021)
task: fix spawn_local source location (#5984)

Changed

macros: use ::core imports instead of ::std in tokio::test (#5973)
sync: use Acquire/Release orderings instead of SeqCst in watch (#6018)

Added

fs: add vectored writes to tokio::fs::File (#5958)
io: add Interest::remove method (#5906)
io: add vectored writes to DuplexStream (#5985)
net: add Apple tvOS support (#6045)
sync: add ?Sized bound to {MutexGuard,OwnedMutexGuard}::map (#5997)
sync: add watch::Receiver::mark_unseen (#5962, #6014, #6017)
sync: add watch::Sender::new (#5998)
sync: add const fn OnceCell::from_value (#5903)

Removed

remove unused stats feature (#5952)

Documented

add missing backticks in code examples (#5938, #6056)
fix typos (#5988, #6030)
process: document that Child::wait is cancel safe (#5977)
sync: add examples for Semaphore (#5939, #5956, #5978, #6031, #6032, #6050)
sync: document that broadcast capacity is a lower bound (#6042)
sync: document that const_new is not instrumented (#6002)
sync: improve cancel-safety documentation for mpsc::Sender::send (#5947)
sync: improve docs for watch channel (#5954)
taskdump: render taskdump documentation on docs.rs (#5972)

Unstable

taskdump: fix potential deadlock (#6036)

#5903: tokio-rs/tokio#5903
#5906: tokio-rs/tokio#5906
#5938: tokio-rs/tokio#5938
#5939: tokio-rs/tokio#5939


... (truncated)


Commits

0457690 chore: prepare Tokio v1.33.0 release (#6059)
4557451 io: implement Seek for SyncIoBridge (#6058)
2bd4376 rt: do not trace tasks while locking OwnedTasks (#6036)
f306bd0 sync: fix unclosed code block in example (#6056)
6b010ac docs: fix new doc warnings in 1.73.0 (#6055)
8cd3383 time: reduce iteration count in short_sleeps test (#6052)
d6ed00c sync: Semaphore doc final cleanup (#6050)
5d29136 docs: add semaphore example for running tests sequentially (#6038)
52b29b3 net: add apple tvos support (#6045)
eaba971 sync: document that broadcast capacity is a lower bound (#6042)
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync R-loom-sync Run loom sync tests on this PR T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants