@@ -22,8 +22,6 @@ pub use wait::*;
22
22
use rcl_bindings:: rcl_context_is_valid;
23
23
use std:: time:: Duration ;
24
24
25
- use std:: pin:: Pin ;
26
-
27
25
pub use rcl_bindings:: rmw_request_id_t;
28
26
29
27
/// Polls the node for new messages and executes the corresponding callbacks.
@@ -107,43 +105,14 @@ pub fn spin(node: &Node) -> Result<(), RclrsError> {
107
105
Ok ( ( ) )
108
106
}
109
107
110
- #[ derive( Clone ) ]
111
- struct RclWaker { }
112
-
113
- fn rclwaker_wake ( _s : & RclWaker ) { }
114
-
115
- fn rclwaker_wake_by_ref ( _s : & RclWaker ) { }
116
-
117
- fn rclwaker_clone ( s : & RclWaker ) -> RawWaker {
118
- let arc = unsafe { Arc :: from_raw ( s) } ;
119
- std:: mem:: forget ( arc. clone ( ) ) ;
120
- RawWaker :: new ( Arc :: into_raw ( arc) as * const ( ) , & VTABLE )
121
- }
122
-
123
- const VTABLE : RawWakerVTable = unsafe {
124
- RawWakerVTable :: new (
125
- |s| rclwaker_clone ( & * ( s as * const RclWaker ) ) ,
126
- |s| rclwaker_wake ( & * ( s as * const RclWaker ) ) ,
127
- |s| rclwaker_wake_by_ref ( & * ( s as * const RclWaker ) ) ,
128
- |s| drop ( Arc :: from_raw ( s as * const RclWaker ) ) ,
129
- )
130
- } ;
131
-
132
- fn rclwaker_into_waker ( s : * const RclWaker ) -> Waker {
133
- let raw_waker = RawWaker :: new ( s as * const ( ) , & VTABLE ) ;
134
- unsafe { Waker :: from_raw ( raw_waker) }
135
- }
136
-
137
108
pub fn spin_until_future_complete < T : Unpin + Clone > (
138
109
node : & node:: Node ,
139
- mut future : Arc < Mutex < Box < RclFuture < T > > > > ,
140
- ) -> Result < <future:: RclFuture < T > as Future >:: Output , RclReturnCode > {
141
- let rclwaker = Arc :: new ( RclWaker { } ) ;
142
- let waker = rclwaker_into_waker ( Arc :: into_raw ( rclwaker) ) ;
143
- let mut cx = std:: task:: Context :: from_waker ( & waker) ;
110
+ mut future : Arc < Mutex < Box < crate :: future:: RclFuture < T > > > > ,
111
+ ) -> Result < <crate :: future:: RclFuture < T > as Future >:: Output , RclReturnCode > {
112
+ let mut cx = crate :: future:: create_rcl_waker_context ( ) ;
144
113
145
114
loop {
146
- let context_valid = unsafe { rcl_context_is_valid ( & mut * node. context . lock ( ) as * mut _ ) } ;
115
+ let context_valid = unsafe { rcl_context_is_valid ( & mut * node. context . lock ( ) ) } ;
147
116
if context_valid {
148
117
if let Some ( error) = spin_once ( node, None ) . err ( ) {
149
118
match error {
0 commit comments