Trait LockableScore

Source
pub trait LockableScore<'a> {
    type ScoreUpdate: 'a + ScoreUpdate;
    type ScoreLookUp: 'a + ScoreLookUp;
    type WriteLocked: DerefMut<Target = Self::ScoreUpdate> + Sized;
    type ReadLocked: Deref<Target = Self::ScoreLookUp> + Sized;

    // Required methods
    fn read_lock(&'a self) -> Self::ReadLocked;
    fn write_lock(&'a self) -> Self::WriteLocked;
}
Expand description

A scorer that is accessed under a lock.

Needed so that calls to ScoreLookUp::channel_penalty_msat in find_route can be made while having shared ownership of a scorer but without requiring internal locking in ScoreUpdate implementations. Internal locking would be detrimental to route finding performance and could result in ScoreLookUp::channel_penalty_msat returning a different value for the same channel.

Required Associated Types§

Source

type ScoreUpdate: 'a + ScoreUpdate

The ScoreUpdate type.

Source

type ScoreLookUp: 'a + ScoreLookUp

The ScoreLookUp type.

Source

type WriteLocked: DerefMut<Target = Self::ScoreUpdate> + Sized

The write locked ScoreUpdate type.

Source

type ReadLocked: Deref<Target = Self::ScoreLookUp> + Sized

The read locked ScoreLookUp type.

Required Methods§

Source

fn read_lock(&'a self) -> Self::ReadLocked

Returns read locked scorer.

Source

fn write_lock(&'a self) -> Self::WriteLocked

Returns write locked scorer.

Implementations on Foreign Types§

Source§

impl<'a, T: Score + 'a> LockableScore<'a> for RefCell<T>

Source§

impl<'a, T: Score + 'a> LockableScore<'a> for Mutex<T>

Source§

impl<'a, T: Score + 'a> LockableScore<'a> for RwLock<T>

Implementors§