Struct sgx_tstd::thread::LocalKey [−][src]
pub struct LocalKey<T: 'static> { /* fields omitted */ }
Methods
impl<T: 'static> LocalKey<T>
[src]
impl<T: 'static> LocalKey<T>
pub const unsafe fn new(
inner: unsafe fn() -> Option<&'static UnsafeCell<Option<T>>>,
init: fn() -> T
) -> LocalKey<T>
[src]
pub const unsafe fn new(
inner: unsafe fn() -> Option<&'static UnsafeCell<Option<T>>>,
init: fn() -> T
) -> LocalKey<T>
pub fn with<F, R>(&'static self, f: F) -> R where
F: FnOnce(&T) -> R,
[src]
pub fn with<F, R>(&'static self, f: F) -> R where
F: FnOnce(&T) -> R,
Acquires a reference to the value in this TLS key.
This will lazily initialize the value if this thread has not referenced this key yet.
Panics
This function will panic!()
if TLS data needs to be destructed,
TCS policy must be Bound.
pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> where
F: FnOnce(&T) -> R,
[src]
pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> where
F: FnOnce(&T) -> R,
Acquires a reference to the value in this TLS key.
This will lazily initialize the value if this thread has not referenced this key yet. If the key has been destroyed (which may happen if this is called in a destructor), this function will return a ThreadLocalError.
Panics
This function will still panic!()
if the key is uninitialized and the
key's initializer panics.