Skip to content

Instantly share code, notes, and snippets.

@reset
Created February 7, 2016 21:22
Show Gist options
  • Save reset/6373c999adf8040bb586 to your computer and use it in GitHub Desktop.
Save reset/6373c999adf8040bb586 to your computer and use it in GitHub Desktop.
Static Mutex in stable Rust
#[macro_use]
extern crate lazy_static;
use std::sync::Mutex;
lazy_static! {
static ref MY_MUTEX: Mutex<()> = Mutex::new(());
}
fn main() {
{
try!(MY_MUTEX.lock());
// do your business
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment