@@ -13,7 +13,7 @@ use rosidl_runtime_rs::Message;
13
13
14
14
pub use self :: { builder:: * , graph:: * } ;
15
15
use crate :: {
16
- rcl_bindings:: * , ActionClient , ActionServer , CancelResponse , Client , ClientBase , Clock ,
16
+ rcl_bindings:: * , ActionClient , ActionClientBase , ActionServer , ActionServerBase , CancelResponse , Client , ClientBase , Clock ,
17
17
Context , ContextHandle , GoalResponse , GoalUuid , GuardCondition , ParameterBuilder ,
18
18
ParameterInterface , ParameterVariant , Parameters , Publisher , QoSProfile , RclrsError ,
19
19
ServerGoalHandle , Service , ServiceBase , Subscription , SubscriptionBase , SubscriptionCallback ,
@@ -64,6 +64,8 @@ pub struct Node {
64
64
pub ( crate ) guard_conditions_mtx : Mutex < Vec < Weak < GuardCondition > > > ,
65
65
pub ( crate ) services_mtx : Mutex < Vec < Weak < dyn ServiceBase > > > ,
66
66
pub ( crate ) subscriptions_mtx : Mutex < Vec < Weak < dyn SubscriptionBase > > > ,
67
+ pub ( crate ) action_servers_mtx : Mutex < Vec < Weak < dyn ActionServerBase > > > ,
68
+ pub ( crate ) action_clients_mtx : Mutex < Vec < Weak < dyn ActionClientBase > > > ,
67
69
time_source : TimeSource ,
68
70
parameter : ParameterInterface ,
69
71
pub ( crate ) handle : Arc < NodeHandle > ,
@@ -207,7 +209,7 @@ impl Node {
207
209
T : rosidl_runtime_rs:: Service ,
208
210
{
209
211
let client = Arc :: new ( Client :: < T > :: new ( Arc :: clone ( & self . handle ) , topic) ?) ;
210
- { self . clients_mtx . lock ( ) . unwrap ( ) } . push ( Arc :: downgrade ( & client) as Weak < dyn ClientBase > ) ;
212
+ self . clients_mtx . lock ( ) . unwrap ( ) . push ( Arc :: downgrade ( & client) as Weak < dyn ClientBase > ) ;
211
213
Ok ( client)
212
214
}
213
215
@@ -220,8 +222,8 @@ impl Node {
220
222
T : rosidl_runtime_rs:: Action ,
221
223
{
222
224
let action_client = Arc :: new ( ActionClient :: < T > :: new ( Arc :: clone ( & self . handle ) , topic) ?) ;
223
- // self.action_clients
224
- // .push(Arc::downgrade(&action_client) as Weak<dyn ActionClientBase>);
225
+ self . action_clients_mtx . lock ( ) . unwrap ( )
226
+ . push ( Arc :: downgrade ( & action_client) as Weak < dyn ActionClientBase > ) ;
225
227
Ok ( action_client)
226
228
}
227
229
@@ -250,8 +252,8 @@ impl Node {
250
252
handle_cancel,
251
253
handle_accepted,
252
254
) ?) ;
253
- // self.action_servers
254
- // .push(Arc::downgrade(&action_server) as Weak<dyn ActionClientBase >);
255
+ self . action_servers_mtx . lock ( ) . unwrap ( )
256
+ . push ( Arc :: downgrade ( & action_server) as Weak < dyn ActionServerBase > ) ;
255
257
Ok ( action_server)
256
258
}
257
259
@@ -269,7 +271,7 @@ impl Node {
269
271
Arc :: clone ( & self . handle . context_handle ) ,
270
272
None ,
271
273
) ) ;
272
- { self . guard_conditions_mtx . lock ( ) . unwrap ( ) }
274
+ self . guard_conditions_mtx . lock ( ) . unwrap ( )
273
275
. push ( Arc :: downgrade ( & guard_condition) as Weak < GuardCondition > ) ;
274
276
guard_condition
275
277
}
@@ -291,7 +293,7 @@ impl Node {
291
293
Arc :: clone ( & self . handle . context_handle ) ,
292
294
Some ( Box :: new ( callback) as Box < dyn Fn ( ) + Send + Sync > ) ,
293
295
) ) ;
294
- { self . guard_conditions_mtx . lock ( ) . unwrap ( ) }
296
+ self . guard_conditions_mtx . lock ( ) . unwrap ( )
295
297
. push ( Arc :: downgrade ( & guard_condition) as Weak < GuardCondition > ) ;
296
298
guard_condition
297
299
}
@@ -330,7 +332,7 @@ impl Node {
330
332
topic,
331
333
callback,
332
334
) ?) ;
333
- { self . services_mtx . lock ( ) . unwrap ( ) }
335
+ self . services_mtx . lock ( ) . unwrap ( )
334
336
. push ( Arc :: downgrade ( & service) as Weak < dyn ServiceBase > ) ;
335
337
Ok ( service)
336
338
}
@@ -354,36 +356,36 @@ impl Node {
354
356
qos,
355
357
callback,
356
358
) ?) ;
357
- { self . subscriptions_mtx . lock ( ) }
359
+ self . subscriptions_mtx . lock ( )
358
360
. unwrap ( )
359
361
. push ( Arc :: downgrade ( & subscription) as Weak < dyn SubscriptionBase > ) ;
360
362
Ok ( subscription)
361
363
}
362
364
363
365
/// Returns the subscriptions that have not been dropped yet.
364
366
pub ( crate ) fn live_subscriptions ( & self ) -> Vec < Arc < dyn SubscriptionBase > > {
365
- { self . subscriptions_mtx . lock ( ) . unwrap ( ) }
367
+ self . subscriptions_mtx . lock ( ) . unwrap ( )
366
368
. iter ( )
367
369
. filter_map ( Weak :: upgrade)
368
370
. collect ( )
369
371
}
370
372
371
373
pub ( crate ) fn live_clients ( & self ) -> Vec < Arc < dyn ClientBase > > {
372
- { self . clients_mtx . lock ( ) . unwrap ( ) }
374
+ self . clients_mtx . lock ( ) . unwrap ( )
373
375
. iter ( )
374
376
. filter_map ( Weak :: upgrade)
375
377
. collect ( )
376
378
}
377
379
378
380
pub ( crate ) fn live_guard_conditions ( & self ) -> Vec < Arc < GuardCondition > > {
379
- { self . guard_conditions_mtx . lock ( ) . unwrap ( ) }
381
+ self . guard_conditions_mtx . lock ( ) . unwrap ( )
380
382
. iter ( )
381
383
. filter_map ( Weak :: upgrade)
382
384
. collect ( )
383
385
}
384
386
385
387
pub ( crate ) fn live_services ( & self ) -> Vec < Arc < dyn ServiceBase > > {
386
- { self . services_mtx . lock ( ) . unwrap ( ) }
388
+ self . services_mtx . lock ( ) . unwrap ( )
387
389
. iter ( )
388
390
. filter_map ( Weak :: upgrade)
389
391
. collect ( )
0 commit comments