Skip to content

⛓️ no_std synchronization primitives using spinlock

License

Notifications You must be signed in to change notification settings

TrAyZeN/spinlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spinlock

CI

no_std synchonization primitives using spinlock.

⚠️ Disclaimer ⚠️: This implementation is for learning purposes if you want to use a spinlock use the crate spin-rs instead.

What is a spinlock ?

In software engineering, a spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available.

From wikipedia.

Roadmap

  • Mutex
  • RwLock
  • Handle panicking

Example

use std::thread;
use std::sync::Arc;

use spinlock::Mutex;

let count = Arc::new(Mutex::new(0));

let count1 = Arc::clone(&count);
let _ = thread::spawn(move || {
    *count1.lock() += 1;
}).join();

assert_eq!(*count.lock(), 1);

Useful links

License

This project is licensed under MIT License.

About

⛓️ no_std synchronization primitives using spinlock

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages