diff options
| author | bors <bors@rust-lang.org> | 2014-06-13 20:57:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-13 20:57:30 +0000 |
| commit | 63dcc9a4df50680686bee852e82a52fbc59b3c27 (patch) | |
| tree | 2a5a941e0da26795babf286edf77f9f225bc906d /src/libsync | |
| parent | e7f11f20e5e72a3b22863a9913df94303321a5ce (diff) | |
| parent | b7af25060a1b0451cb06085ba5893980bc4e5333 (diff) | |
| download | rust-63dcc9a4df50680686bee852e82a52fbc59b3c27.tar.gz rust-63dcc9a4df50680686bee852e82a52fbc59b3c27.zip | |
auto merge of #14867 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libsync')
| -rw-r--r-- | src/libsync/mutex.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs index 6b9ff3cf052..ef558d3f924 100644 --- a/src/libsync/mutex.rs +++ b/src/libsync/mutex.rs @@ -97,7 +97,14 @@ pub static NATIVE_BLOCKED: uint = 1 << 2; /// drop(guard); // unlock the lock /// ``` pub struct Mutex { - lock: StaticMutex, + // Note that this static mutex is in a *box*, not inlined into the struct + // itself. This is done for memory safety reasons with the usage of a + // StaticNativeMutex inside the static mutex above. Once a native mutex has + // been used once, its address can never change (it can't be moved). This + // mutex type can be safely moved at any time, so to ensure that the native + // mutex is used correctly we box the inner lock to give it a constant + // address. + lock: Box<StaticMutex>, } #[deriving(PartialEq, Show)] @@ -458,7 +465,7 @@ impl Mutex { /// Creates a new mutex in an unlocked state ready for use. pub fn new() -> Mutex { Mutex { - lock: StaticMutex { + lock: box StaticMutex { state: atomics::AtomicUint::new(0), flavor: Unsafe::new(Unlocked), green_blocker: Unsafe::new(0), |
