Struct fbp::fbp_threadsafe_wrapper::ThreadSafeType[][src]

pub struct ThreadSafeType<T: Clone> { /* fields omitted */ }
Expand description

Generic Thread safe type

Implementations

Creates a new ThreadSafeType for a specific type

Example

Basic usage:

use fbp::fbp_threadsafe_wrapper::*;

let safe_bool = ThreadSafeType::new(false);

Create a new ThreadSafeType from an Arc<Mutex>

Example

Basic usage:

use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};

let an_arc = Arc::new(Mutex::new(false));

let safe_bool = ThreadSafeType::create(an_arc);

Return a MutexGuard of the underlying data

NOTE: MutexGuard will dereference to the underlying type

Example

Basic usage:

use fbp::fbp_threadsafe_wrapper::*;
use std::ops::Deref;

let safe_bool = ThreadSafeType::new(false);
let the_value = safe_bool.get_type();
if *the_value.deref() == true {
	println!("The value is true");
} else {
	println!("The value is false");
}

Return the underlying arc used by the ThreadSafeType

Example

Basic usage:

use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};

let safe_bool = ThreadSafeType::new(false);
let the_arc = safe_bool.get_arc();

Change the underlying arc used by the threadSafeType

Example

Basic usage:

use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};

let mut safe_bool = ThreadSafeType::new(false);
let new_arc = Arc::new(Mutex::new(true));
safe_bool.set_arc(new_arc);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.