Struct fbp::fbp_threadsafe_wrapper::ThreadSafeOptionType [−][src]
pub struct ThreadSafeOptionType<T> { /* fields omitted */ }
Expand description
Generic thread safe Option
Implementations
Creates a new ThreadSafeOptionType for a specific type
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
let safe_bool: ThreadSafeOptionType<bool> = ThreadSafeOptionType::new(None);
Create a new ThreadSafeOptionType from an Arc<Mutex<Option
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};
let an_arc = Arc::new(Mutex::new(Some(false)));
let safe_bool_option = ThreadSafeType::create(an_arc);
Return the underlying arc used by the ThreadSafeOptionType
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};
let safe_bool_option = ThreadSafeOptionType::new(Some(false));
let the_arc = safe_bool_option.get_arc();
Change the underlying arc used by the ThreadSafeOptionType
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};
let mut safe_bool_option = ThreadSafeOptionType::new(Some(false));
let new_arc = Arc::new(Mutex::new(Some(true)));
safe_bool_option.set_arc(new_arc);
Change the underlying option in a MutexGuard
NOTE: MutexGuard<Option
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};
use std::ops::Deref;
let mut safe_bool_option = ThreadSafeOptionType::new(Some(false));
let the_value = safe_bool_option.get_option();
if the_value.deref().unwrap() == true {
println!("The value is true");
} else {
println!("The value is false");
}
Replace the underlying option in a ThreadSafeOptionType with a new option
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
use std::sync::{Arc, Mutex, MutexGuard};
use std::ops::{DerefMut, Deref};
let mut safe_bool_option = ThreadSafeOptionType::new(None);
let new_option = Some(true);
safe_bool_option.set_option(new_option);
Implement is_none for a ThreadSafeOptionType so that it works like a regular option
Example
Basic usage:
use fbp::fbp_threadsafe_wrapper::*;
let mut safe_bool_option: ThreadSafeOptionType<bool> = ThreadSafeOptionType::new(None);
assert!(safe_bool_option.is_none());
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for ThreadSafeOptionType<T>
impl<T> Send for ThreadSafeOptionType<T> where
T: Send,
impl<T> Sync for ThreadSafeOptionType<T> where
T: Send,
impl<T> Unpin for ThreadSafeOptionType<T>
impl<T> UnwindSafe for ThreadSafeOptionType<T>
Blanket Implementations
Mutably borrows from an owned value. Read more