[][src]Struct msp430_atomic::AtomicI16

pub struct AtomicI16 { /* fields omitted */ }

An integer type which can be safely shared between threads.

This type has the same in-memory representation as the underlying integer type.

Methods

impl AtomicI16[src]

pub const fn new(v: i16) -> Self[src]

Creates a new atomic integer.

Examples

use msp430_atomic::AtomicIsize;

let atomic_forty_two  = AtomicIsize::new(42);

pub fn get_mut(&mut self) -> &mut i16[src]

Returns a mutable reference to the underlying integer.

This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.

Examples

use msp430_atomic::AtomicIsize;

let mut some_isize = AtomicIsize::new(10);
assert_eq!(*some_isize.get_mut(), 10);
*some_isize.get_mut() = 5;
assert_eq!(some_isize.load(), 5);

pub fn into_inner(self) -> i16[src]

Consumes the atomic and returns the contained value.

This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples

use msp430_atomic::AtomicIsize;

let some_isize = AtomicIsize::new(5);
assert_eq!(some_isize.into_inner(), 5);

pub fn load(&self) -> i16[src]

Loads a value from the atomic integer.

Examples

use msp430_atomic::AtomicIsize;

let some_isize = AtomicIsize::new(5);

assert_eq!(some_isize.load(), 5);

pub fn store(&self, val: i16)[src]

Stores a value into the atomic integer.

Examples

use msp430_atomic::AtomicIsize;

let some_isize = AtomicIsize::new(5);

some_isize.store(10);
assert_eq!(some_isize.load(), 10);

pub fn add(&self, val: i16)[src]

Adds to the current value, returning the previous value.

This operation wraps around on overflow.

Examples

use msp430_atomic::AtomicIsize;

let foo = AtomicIsize::new(0);
foo.add(10);
assert_eq!(foo.load(), 10);

pub fn sub(&self, val: i16)[src]

Subtracts from the current value, returning the previous value.

This operation wraps around on overflow.

Examples

use msp430_atomic::AtomicIsize;

let foo = AtomicIsize::new(0);
foo.sub(10);
assert_eq!(foo.load(), -10);

pub fn and(&self, val: i16)[src]

Bitwise "and" with the current value.

Performs a bitwise "and" operation on the current value and the argument val, and sets the new value to the result.

Examples

use msp430_atomic::AtomicIsize;

let foo = AtomicIsize::new(0b101101);
foo.and(0b110011);
assert_eq!(foo.load(), 0b100001);

pub fn or(&self, val: i16)[src]

Bitwise "or" with the current value.

Performs a bitwise "or" operation on the current value and the argument val, and sets the new value to the result.

Examples

use msp430_atomic::AtomicIsize;

let foo = AtomicIsize::new(0b101101);
foo.or(0b110011);
assert_eq!(foo.load(), 0b111111);

pub fn xor(&self, val: i16)[src]

Bitwise "xor" with the current value.

Performs a bitwise "xor" operation on the current value and the argument val, and sets the new value to the result.

Examples

use msp430_atomic::AtomicIsize;

let foo = AtomicIsize::new(0b101101);
foo.xor(0b110011);
assert_eq!(foo.load(), 0b011110);

Trait Implementations

impl Debug for AtomicI16[src]

impl Default for AtomicI16[src]

impl Sync for AtomicI16[src]

Auto Trait Implementations

impl Send for AtomicI16

impl Unpin for AtomicI16

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.