]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add a constructor to MultiThreadedLockableScore
authorMatt Corallo <git@bluematt.me>
Sat, 18 Dec 2021 03:38:15 +0000 (03:38 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 18 Dec 2021 20:20:23 +0000 (20:20 +0000)
...as otherwise the struct is rather useless.

lightning/src/routing/scoring.rs

index 2b2839d69db82ec2640f7f24c02824b4d79b0b0b..20a8afcabcf827298229cb44ff9903cbc000c9f6 100644 (file)
@@ -168,6 +168,14 @@ impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore<T> {
        }
 }
 
+#[cfg(c_bindings)]
+impl<T: Score> MultiThreadedLockableScore<T> {
+       /// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].
+       pub fn new(score: T) -> Self {
+               MultiThreadedLockableScore { score: Mutex::new(score) }
+       }
+}
+
 #[cfg(c_bindings)]
 /// (C-not exported)
 impl<'a, T: Writeable> Writeable for RefMut<'a, T> {