Simple Lock

License builds.sr.ht status Latest version Documentation

NOTE: Still a WIP package.

This package provides a simple locking abstraction for inter-process/thread synchronization.

Features:

By default, no features will be enabled and only the Lock trait and utility functionality will be available. This can be useful if you wish to hand-roll your own Lock, but don't want to re-write the utility functions.

Current implementations:

Examples:

```rust use simplelock::*;

fn main() -> SimpleLockResult<()> { // Based on the "feature" enabled, this will create the default lock. // Will return a SimpleLockError on error, or if no lock type was enabled. let mut lock: Lock = defaultlock("myapp_name")?;

// One utility function provided, simple critical-section locking. 
let result = lock_until_finished(
    lock,
    || {
        /// Some critical code.
    })?;

// ... Do something with the result.

} ```

If you wanted to implement your own lock, you can implement the Lock trait and use it with all the same utility functionality provided by this package. If you do not enable any features, this package is only the trait and utility functions.

Caveats:

If you are ok with the below, then go ahead and use this package.