]> git.lizzy.rs Git - rust.git/commit
auto merge of #15995 : Ryman/rust/sync_spsc_peek, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 1 Aug 2014 22:05:58 +0000 (22:05 +0000)
committerbors <bors@rust-lang.org>
Fri, 1 Aug 2014 22:05:58 +0000 (22:05 +0000)
commit292caefb26c7f99a064a1ed6a8ba37ec5375e88e
treee00782f524dccaa0fd75db74c97fc7c3d33e2795
parent55b24051be0c7ee7ebfddece0d58f3f9279bffa5
parent7b817b6ab97f31d96dc935278fa4d34e4b510782
auto merge of #15995 : Ryman/rust/sync_spsc_peek, r=alexcrichton

The current spsc implementation doesn't enforce single-producer
single-consumer usage and also allows unsafe memory use through
peek & pop.

For safer usage, `new` now returns a pair of owned objects which
only allow consumer or producer behaviors through an `Arc`.
Through restricting the mutability of the receiver to `mut` the
peek and pop behavior 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::unchecked_new(x) }

[breaking-change]

For an example of broken behavior, check the added test which uses the unchecked constructor.