Skip to content

rustysoft/arc-guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArcGuard

Guard around Arc<Mutex<T>> allowing you to write less boilerplate code.

Full Documentation can be read here.

Example

Before:

use std::sync::{Arc, Mutex};

let indicator = Arc::new(Mutex::new(Indicator::new()));
let indicator_clone = indicator.clone();
let indicator_clone = indicator_clone.lock().expect("Unable to lock indicator.");

indicator_clone.do_something();

drop(indicator_clone);

After:

use arc_guard::ArcGuard;

let indicator = ArcGuard::new(Indicator::new());

indicator.execute(|indicator| {
    let indicator = indicator.lock().expect("Unable to lock indicator.");
    indicator.do_something();
});

About

Guard around Arc<Mutex<T>> allowing you to write less boilerplate code.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages