Trait SyncEstimatorArray

Source
pub trait SyncEstimatorArray<L: EstimationLogic + ?Sized>: Sync {
    // Required methods
    fn logic(&self) -> &L;
    unsafe fn set(&self, index: usize, content: &L::Backend);
    unsafe fn get(&self, index: usize, content: &mut L::Backend);
    unsafe fn clear(&self);
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

An array of mutable estimators sharing a EstimationLogic that can be shared between threads.

This trait has the same purpose of EstimatorArrayMut, but can be shared between threads as it implements interior mutability. It follows a logic similar to a slice of SyncCell: it is possible to get or set the backend of an estimator, but not to obtain a reference to a backend.

§Safety

The methods of this trait are unsafe because multiple thread can concurrently access the same estimator array. The caller must ensure that there are no data races.

Required Methods§

Source

fn logic(&self) -> &L

Returns the logic used by the estimators in the array.

Source

unsafe fn set(&self, index: usize, content: &L::Backend)

Sets the backend of the estimator at index to the given backend, using a shared reference to the estimator array.

§Safety

The caller must ensure that the backend is correct for the logic of the estimator array, and that there are no data races.

Source

unsafe fn get(&self, index: usize, content: &mut L::Backend)

Copies the backend of the estimator at index to the given backend, using a shared reference to the estimator array.

§Safety

The caller must ensure that the backend is correct for the logic of the estimator array, and that there are no data races.

Source

unsafe fn clear(&self)

Clears all estimators in the array.

§Safety

The caller must ensure that there are no data races.

Source

fn len(&self) -> usize

Returns the number of estimators in the array.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the array contains no estimators.

Implementors§