@@ -188,12 +188,39 @@ pub struct MultiThreadedLockableScore<S: Score> {
188
188
score : Mutex < S > ,
189
189
}
190
190
#[ cfg( c_bindings) ]
191
- /// (C-not exported)
191
+ /// A locked `MultiThreadedLockableScore`.
192
+ pub struct MultiThreadedLockableScoreLock < ' a , S : Score > ( MutexGuard < ' a , S > ) ;
193
+ #[ cfg( c_bindings) ]
194
+ impl < ' a , T : Score + ' a > Score for MultiThreadedLockableScoreLock < ' a , T > {
195
+ fn channel_penalty_msat ( & self , scid : u64 , source : & NodeId , target : & NodeId , usage : ChannelUsage ) -> u64 {
196
+ self . 0 . channel_penalty_msat ( scid, source, target, usage)
197
+ }
198
+ fn payment_path_failed ( & mut self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
199
+ self . 0 . payment_path_failed ( path, short_channel_id)
200
+ }
201
+ fn payment_path_successful ( & mut self , path : & [ & RouteHop ] ) {
202
+ self . 0 . payment_path_successful ( path)
203
+ }
204
+ fn probe_failed ( & mut self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
205
+ self . 0 . probe_failed ( path, short_channel_id)
206
+ }
207
+ fn probe_successful ( & mut self , path : & [ & RouteHop ] ) {
208
+ self . 0 . probe_successful ( path)
209
+ }
210
+ }
211
+ #[ cfg( c_bindings) ]
212
+ impl < ' a , T : Score + ' a > Writeable for MultiThreadedLockableScoreLock < ' a , T > {
213
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
214
+ self . 0 . write ( writer)
215
+ }
216
+ }
217
+
218
+ #[ cfg( c_bindings) ]
192
219
impl < ' a , T : Score + ' a > LockableScore < ' a > for MultiThreadedLockableScore < T > {
193
- type Locked = MutexGuard < ' a , T > ;
220
+ type Locked = MultiThreadedLockableScoreLock < ' a , T > ;
194
221
195
- fn lock ( & ' a self ) -> MutexGuard < ' a , T > {
196
- Mutex :: lock ( & self . score ) . unwrap ( )
222
+ fn lock ( & ' a self ) -> MultiThreadedLockableScoreLock < ' a , T > {
223
+ MultiThreadedLockableScoreLock ( Mutex :: lock ( & self . score ) . unwrap ( ) )
197
224
}
198
225
}
199
226
0 commit comments