diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-28 19:44:52 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-12-31 20:15:03 -0800 |
| commit | c22fed9424a907beab53f6c6cd54afeff039f1b3 (patch) | |
| tree | 36917eae31e165819adbdff2d9aea95b3c3073a8 /src/libnative | |
| parent | f3370295b738c8b4c80fa8fc8449c0c3545b1b35 (diff) | |
| download | rust-c22fed9424a907beab53f6c6cd54afeff039f1b3.tar.gz rust-c22fed9424a907beab53f6c6cd54afeff039f1b3.zip | |
Convert relevant static mutexes to Once
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/net.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index aaa95ce0cfb..9f307fcebb0 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -164,19 +164,14 @@ pub fn init() { } unsafe { - use std::unstable::mutex::{Mutex, MUTEX_INIT}; - static mut LOCK: Mutex = MUTEX_INIT; - static mut INITIALIZED: bool = false; - if INITIALIZED { return } - LOCK.lock(); - if !INITIALIZED { + use std::unstable::mutex::{Once, ONCE_INIT}; + static mut INIT: Once = ONCE_INIT; + INIT.doit(|| { let mut data: WSADATA = intrinsics::init(); let ret = WSAStartup(0x202, // version 2.2 &mut data); assert_eq!(ret, 0); - INITIALIZED = true; - } - LOCK.unlock(); + }); } } |
