Struct spinlock::Spinlock [] [src]

pub struct Spinlock<T> { /* fields omitted */ }

A wrapper for the data giving access in a thread-safe manner

Methods

impl<T> Spinlock<T>
[src]

Creates a new spinlock wrapping the supplied data.

Locks the spinlock and returns a guard.

The returned value may be dereferenced for data access and the lock will be dropped when the guard falls out of scope.

let mylock = spinlock::Spinlock::new(0);
{
    let mut data = mylock.lock();
    // The lock is now locked and the data can be accessed
    *data += 1;
}
// The lock is dropped

Trait Implementations

impl<T> Sync for Spinlock<T>
[src]