Skip to content

A no_std mutex for single thread environments

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

richardanaya/no_mutex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

no_mutex

this only works on nightly

A mutex like singleton construct for single threaded applications.

  • Only requires no_std
  • Gives you Sync and Send container
  • Lazily loads the mutex value with Default
  • panics if you lock it twice since deadlocking a single threaded app would be pointless
use no_mutex::Mutex;

static FOO: Mutex<Foo> = Mutex::default();

#[derive(Debug)]
struct Foo {
    i:u32
}

impl Default for Foo {
    fn default() -> Self {
        Foo { i: 42 }
    }
}

fn main() {
    let r = FOO.lock();
    println!("{:?}",r);
}

About

A no_std mutex for single thread environments

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages