Skip to content

Commit b6b725b

Browse files
committed
---
yaml --- r: 106238 b: refs/heads/auto c: 53e451f h: refs/heads/master v: v3
1 parent ce789ef commit b6b725b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 3572a30e7a4fec7f0bb0957fc72588757111f14e
16+
refs/heads/auto: 53e451f4106c0eb6614b4c534744e81c6100cbbd
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libsync/sync/one.rs renamed to branches/auto/src/libsync/one.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
1616
use std::int;
1717
use std::sync::atomics;
18-
use sync::mutex::{StaticMutex, MUTEX_INIT};
18+
19+
use mutex::{StaticMutex, MUTEX_INIT};
1920

2021
/// A type which can be used to run a one-time global initialization. This type
2122
/// is *unsafe* to use because it is built on top of the `Mutex` in this module.
@@ -62,7 +63,7 @@ impl Once {
6263
///
6364
/// When this function returns, it is guaranteed that some initialization
6465
/// has run and completed (it may not be the closure specified).
65-
pub fn doit(&mut self, f: ||) {
66+
pub fn doit(&self, f: ||) {
6667
// Implementation-wise, this would seem like a fairly trivial primitive.
6768
// The stickler part is where our mutexes currently require an
6869
// allocation, and usage of a `Once` should't leak this allocation.
@@ -101,14 +102,13 @@ impl Once {
101102
// If the count is negative, then someone else finished the job,
102103
// otherwise we run the job and record how many people will try to grab
103104
// this lock
104-
{
105-
let _guard = self.mutex.lock();
106-
if self.cnt.load(atomics::SeqCst) > 0 {
107-
f();
108-
let prev = self.cnt.swap(int::MIN, atomics::SeqCst);
109-
self.lock_cnt.store(prev, atomics::SeqCst);
110-
}
105+
let guard = self.mutex.lock();
106+
if self.cnt.load(atomics::SeqCst) > 0 {
107+
f();
108+
let prev = self.cnt.swap(int::MIN, atomics::SeqCst);
109+
self.lock_cnt.store(prev, atomics::SeqCst);
111110
}
111+
drop(guard);
112112

113113
// Last one out cleans up after everyone else, no leaks!
114114
if self.lock_cnt.fetch_add(-1, atomics::SeqCst) == 1 {

0 commit comments

Comments
 (0)