Skip to main content

SharedTable

Struct SharedTable 

Source
pub struct SharedTable<K, M, S> { /* private fields */ }
Expand description

A transposition table several threads search with at once: SlotTable shards, each behind its own lock.

A key’s shard comes from all bits of TableKey::slot, mixed, and its slot within the shard from the low bits, so threads rarely wait for the same lock. Searchers use it through a shared reference: &SharedTable implements Table, so each thread builds its own Searcher::with_table(&table), as deepen_shared does for Lazy SMP.

Available with the parallel feature, which needs std.

Implementations§

Source§

impl<K: TableKey, M: Clone, S: Clone> SharedTable<K, M, S>

Source

pub fn new(capacity: usize, shards: usize) -> Self

A table with about capacity slots in shards shards, both rounded up to powers of two (at least one).

§Panics

Panics if a rounded size does not fit in usize.

Source

pub fn capacity(&self) -> usize

The number of slots over all shards.

Source

pub fn clear(&self)

Empties every shard, for example before searching a different game.

Trait Implementations§

Source§

impl<K: Debug, M: Debug, S: Debug> Debug for SharedTable<K, M, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: TableKey, M: Clone, S: Clone> Table<K, M, S> for &SharedTable<K, M, S>

Source§

fn probe(&mut self, key: &K) -> Option<Entry<M, S>>

The entry stored for key, if any.
Source§

fn store(&mut self, key: K, entry: Entry<M, S>)

Stores entry for key; the table may keep or drop it, or evict another entry.

Auto Trait Implementations§

§

impl<K, M, S> Forget for SharedTable<K, M, S>

§

impl<K, M, S> Freeze for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: Freeze,

§

impl<K, M, S> Move for SharedTable<K, M, S>

§

impl<K, M, S> RefUnwindSafe for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: RefUnwindSafe,

§

impl<K, M, S> Send for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: Send,

§

impl<K, M, S> Sync for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: Sync,

§

impl<K, M, S> Unpin for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: Unpin,

§

impl<K, M, S> UnsafeUnpin for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: UnsafeUnpin,

§

impl<K, M, S> UnwindSafe for SharedTable<K, M, S>
where Vec<Mutex<SlotTable<K, M, S>>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.