[][src]Trait arc_swap::gen_lock::LockStorage

pub unsafe trait LockStorage: Default {
    type Shards: AsRef<[Shard]>;
    fn gen_idx(&self) -> &AtomicUsize;
fn shards(&self) -> &Self::Shards;
fn choose_shard(&self) -> usize; }

Abstraction of the place where generation locks are stored.

The trait is unsafe because if the trait messes up with the values stored in there in any way (or makes the values available to something else that messes them up), this can cause UB and daemons and discomfort to users and such. The library expects it is the only one storing values there. In other words, it is expected the trait is only a dumb storage and doesn't actively do anything.

Associated Types

type Shards: AsRef<[Shard]>

The type for keeping several shards.

In general, it is expected to be a fixed-size array, but different implementations can have different sizes.

Loading content...

Required methods

fn gen_idx(&self) -> &AtomicUsize

Access to the generation index.

Must return the same instance of the AtomicUsize for the lifetime of the storage, must start at 0 and the trait itself must not modify it. Must be async-signal-safe.

fn shards(&self) -> &Self::Shards

Access to the shards storage.

Must return the same instance of the shards for the lifetime of the storage. Must start zeroed-out and the trait itself must not modify it.

fn choose_shard(&self) -> usize

Pick one shard of the all selected.

Returns the index of one of the shards. The choice can be arbitrary, but it should be fast and avoid collisions.

Loading content...


impl LockStorage for Global[src]

impl LockStorage for PrivateUnsharded[src]

impl<S: AsRef<[Shard]> + Default> LockStorage for PrivateSharded<S>[src]

type Shards = S

Loading content...