[][src]Function swym::thread_key::get

pub fn get() -> ThreadKey

Returns a handle to swym's thread local state.

Note

Reusing the same ThreadKey between transactions is slightly more efficient due to the costs of access thread local memory, and (non-atomic) reference counting.

Examples

use swym::{tcell::TCell, thread_key, tx::Ordering};
let thread_key = thread_key::get();

let x = TCell::new(0);

thread_key.rw(|tx| Ok(x.set(tx, 1)?));

let one = thread_key.read(|tx| Ok(x.get(tx, Ordering::default())?));

assert_eq!(one, 1);