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

    // 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§

type ScoreUpdate: 'a + ScoreUpdate

The ScoreUpdate type.

type ScoreLookUp: 'a + ScoreLookUp

The ScoreLookUp type.

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

The write locked ScoreUpdate type.

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

The read locked ScoreLookUp type.

Required Methods§

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

Returns read locked scorer.

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

Returns write locked scorer.

Implementations on Foreign Types§

§

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

§

type ScoreUpdate = T

§

type ScoreLookUp = T

§

type WriteLocked = RefMut<'a, <RefCell<T> as LockableScore<'a>>::ScoreUpdate>

§

type ReadLocked = Ref<'a, <RefCell<T> as LockableScore<'a>>::ScoreLookUp>

§

fn write_lock(&'a self) -> <RefCell<T> as LockableScore<'a>>::WriteLocked

§

fn read_lock(&'a self) -> <RefCell<T> as LockableScore<'a>>::ReadLocked

§

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

§

type ScoreUpdate = T

§

type ScoreLookUp = T

§

type WriteLocked = MutexGuard<'a, <Mutex<T> as LockableScore<'a>>::ScoreUpdate>

§

type ReadLocked = MutexGuard<'a, <Mutex<T> as LockableScore<'a>>::ScoreLookUp>

§

fn read_lock(&'a self) -> <Mutex<T> as LockableScore<'a>>::ReadLocked

§

fn write_lock(&'a self) -> <Mutex<T> as LockableScore<'a>>::WriteLocked

§

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

Implementors§