-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libsync: Add safer abstraction for SPSC queue.
The current spsc implementation doesn't enforce single-producer single-consumer usage and also allows unsafe memory use through peek & pop. For safer usage, `spsc_queue::queue` now returns a pair of owned objects which only allow consumer or producer behaviours through an `Arc`. Through restricting the mutability of the receiver to `mut` the peek and pop behaviour becomes safe again, with the compiler complaining about usage which could lead to problems. To fix code broken from this, update: Queue::new(x) -> unsafe { Queue::new(x) } [breaking-change]
- Loading branch information
Showing
2 changed files
with
143 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at Ryman@7b817b6
7b817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging Ryman/rust/sync_spsc_peek = 7b817b6 into auto
7b817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ryman/rust/sync_spsc_peek = 7b817b6 merged ok, testing candidate = 292caef
7b817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/640
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/640
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/639
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/640
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/637
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/638
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/637
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/643
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/638
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/637
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/640
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/638
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/638
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/639
7b817b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 292caef