std: add an RAII unlocker to Mutex.
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
This commit is contained in:
@@ -157,7 +157,7 @@ pub mod dl {
|
||||
unsafe {
|
||||
// dlerror isn't thread safe, so we need to lock around this entire
|
||||
// sequence
|
||||
lock.lock();
|
||||
let _guard = lock.lock();
|
||||
let _old_error = dlerror();
|
||||
|
||||
let result = f();
|
||||
@@ -168,7 +168,7 @@ pub mod dl {
|
||||
} else {
|
||||
Err(str::raw::from_c_str(last_error))
|
||||
};
|
||||
lock.unlock();
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user