Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 664 Bytes

README.md

File metadata and controls

24 lines (18 loc) · 664 Bytes

Spin Lock

A minimal implementation of a thread safe spin-lock using rust

Usage

  1. Create a new lock by using
let sl = SpinLock::new(Vec::new())
  1. You can lock this object by using .lock() method
sl.lock()
  1. Unlocking happens when the object gets destroyed so we don't need to explicitly call the .unlock() method.

NOTE: SpinLock is usually used on the threads which does not wait for long time on some stuff to happen. If your threads happens to wait for longer times while processing something, you should not consider using this. Instead you can use Mutex which could be found inside the standard library.