Created
May 26, 2017 07:46
-
-
Save anonymous/0e0a691d432433c4e2a2455f1a0b00b2 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[post("/tablet-reg-mode-status")] | |
fn reg_mode_status() -> Res<bool> { | |
ok(REGISTER_MODE.load(Ordering::Relaxed)) | |
} | |
#[post("/tablet-reg-mode-toggle")] | |
fn reg_mode_toggle(_me: Admin) -> Res<bool> { | |
for { | |
let old = REGISTER_MODE.load(Ordering::SeqCst); | |
let new = !old; | |
if REGISTER_MODE.compare_and_swap(old, new, Ordering::SeqCst) { | |
break; | |
} | |
} | |
ok(reg) | |
} | |
use std::sync::atomic::{AtomicBool, Ordering}; | |
lazy_static! { | |
static ref REGISTER_MODE: AtomicBool = AtomicBool::new(false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment