Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2017 07:46
Show Gist options
  • Save anonymous/0e0a691d432433c4e2a2455f1a0b00b2 to your computer and use it in GitHub Desktop.
Save anonymous/0e0a691d432433c4e2a2455f1a0b00b2 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#[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