# Struct crossbeam::epoch::Atomic [−] [src]

    pub struct Atomic<T> { /* fields omitted */ }

Like `std::sync::atomic::AtomicPtr`.

Provides atomic access to a (nullable) pointer of type `T`, interfacing with the `Owned` and `Shared` types.

## Methods

### `impl<T> Atomic<T>`
[src]

#### `pub fn null() -> Atomic<T>`
[src]

#### `pub fn new(data: T) -> Atomic<T>`
[src]

Create a new atomic pointer

#### `pub fn load<'a>(&self, ord: Ordering, _: &'a Guard) -> Option<Shared<'a, T>>`
[src]

Do an atomic load with the given memory ordering.

In order to perform the load, we must pass in a borrow of a `Guard`. This is a way of guaranteeing that the thread has pinned the epoch for the entire lifetime `'a`. In return, you get an optional `Shared` pointer back (`None` if the `Atomic` is currently null), with lifetime tied to the guard.

# Panics

Panics if `ord` is `Release` or `AcqRel`.

#### `pub fn store(&self, val: Option<Owned<T>>, ord: Ordering)`
[src]

Do an atomic store with the given memory ordering.

Transfers ownership of the given `Owned` pointer, if any. Since no lifetime information is acquired, no `Guard` value is needed.

# Panics

Panics if `ord` is `Acquire` or `AcqRel`.

#### `pub fn store_and_ref<'a>(
&self,
val: Owned<T>,
ord: Ordering,
_: &'a Guard
) -> Shared<'a, T>`
[src]

Do an atomic store with the given memory ordering, immediately yielding a shared reference to the pointer that was stored.

Transfers ownership of the given `Owned` pointer, yielding a `Shared` reference to it. Since the reference is valid only for the curent epoch, it's lifetime is tied to a `Guard` value.

# Panics

Panics if `ord` is `Acquire` or `AcqRel`.

#### `pub fn store_shared(&self, val: Option<Shared<T>>, ord: Ordering)`
[src]

Do an atomic store of a `Shared` pointer with the given memory ordering.

This operation does not require a guard, because it does not yield any new information about the lifetime of a pointer.

# Panics

Panics if `ord` is `Acquire` or `AcqRel`.

#### `pub fn cas(
&self,
old: Option<Shared<T>>,
new: Option<Owned<T>>,
ord: Ordering
) -> Result<(), Option<Owned<T>>>`
[src]

Do a compare-and-set from a `Shared` to an `Owned` pointer with the given memory ordering.

As with `store`, this operation does not require a guard; it produces no new lifetime information. The `Result` indicates whether the CAS succeeded; if not, ownership of the `new` pointer is returned to the caller.

#### `pub fn cas_and_ref<'a>(
&self,
old: Option<Shared<T>>,
new: Owned<T>,
ord: Ordering,
_: &'a Guard
) -> Result<Shared<'a, T>, Owned<T>>`
[src]

Do a compare-and-set from a `Shared` to an `Owned` pointer with the given memory ordering, immediatley acquiring a new `Shared` reference to the previously-owned pointer if successful.

This operation is analogous to `store_and_ref`.

#### `pub fn cas_shared(
&self,
old: Option<Shared<T>>,
new: Option<Shared<T>>,
ord: Ordering
) -> bool`
[src]

Do a compare-and-set from a `Shared` to another `Shared` pointer with the given memory ordering.

The boolean return value is `true` when the CAS is successful.

#### `pub fn swap<'a>(
&self,
new: Option<Owned<T>>,
ord: Ordering,
_: &'a Guard
) -> Option<Shared<'a, T>>`
[src]

Do an atomic swap with an `Owned` pointer with the given memory ordering.

#### `pub fn swap_shared<'a>(
&self,
new: Option<Shared<T>>,
ord: Ordering,
_: &'a Guard
) -> Option<Shared<'a, T>>`
[src]

Do an atomic swap with a `Shared` pointer with the given memory ordering.

## Trait Implementations

### `impl<T: Debug> Debug for Atomic<T>`
[src]

#### `fn fmt(&self, __arg_0: &mut Formatter) -> Result`
[src]

Formats the value using the given formatter. Read more

### `impl<T: Sync> Send for Atomic<T>`
[src]

### `impl<T: Sync> Sync for Atomic<T>`
[src]

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)