@@ -112,54 +112,3 @@ pub fn spin(node: &Node) -> Result<(), RclrsError> {
112
112
}
113
113
Ok ( ( ) )
114
114
}
115
-
116
- /// Convenience function for calling [`rclrs::spin_once`] in a loop.
117
- ///
118
- /// This function additionally checks that the context is still valid.
119
- pub fn spin_some ( node : & Node ) -> Result < ( ) , RclrsError > {
120
- // The context_is_valid functions exists only to abstract away ROS distro differences
121
- #[ cfg( ros_distro = "foxy" ) ]
122
- // SAFETY: No preconditions for this function.
123
- let context_is_valid = || unsafe { rcl_context_is_valid ( & mut * node. context . lock ( ) ) } ;
124
- #[ cfg( not( ros_distro = "foxy" ) ) ]
125
- // SAFETY: No preconditions for this function.
126
- let context_is_valid = || unsafe { rcl_context_is_valid ( & * node. context . lock ( ) ) } ;
127
-
128
- if context_is_valid ( ) {
129
- if let Some ( error) = spin_once ( node, Some ( std:: time:: Duration :: from_millis ( 500 ) ) ) . err ( ) {
130
- match error. code {
131
- RclReturnCode :: Timeout => ( ) ,
132
- _ => return Err ( error) ,
133
- }
134
- }
135
- }
136
- Ok ( ( ) )
137
- }
138
-
139
- pub fn spin_until_future_complete < T : Unpin + Clone > (
140
- node : & node:: Node ,
141
- future : Arc < Mutex < Box < crate :: future:: RclFuture < T > > > > ,
142
- ) -> Result < <future:: RclFuture < T > as Future >:: Output , RclrsError > {
143
- let rclwaker = Arc :: new ( crate :: future:: RclWaker { } ) ;
144
- let waker = crate :: future:: rclwaker_into_waker ( Arc :: into_raw ( rclwaker) ) ;
145
- let mut cx = std:: task:: Context :: from_waker ( & waker) ;
146
-
147
- loop {
148
- let context_valid = unsafe { rcl_context_is_valid ( & mut * node. context . lock ( ) ) } ;
149
- if context_valid {
150
- if let Some ( error) = spin_once ( node, None ) . err ( ) {
151
- match error {
152
- RclrsError {
153
- code : RclReturnCode :: Timeout ,
154
- ..
155
- } => continue ,
156
- error => return Err ( error) ,
157
- } ;
158
- } ;
159
- match Future :: poll ( Pin :: new ( & mut * future. lock ( ) ) , & mut cx) {
160
- Poll :: Ready ( val) => break Ok ( val) ,
161
- Poll :: Pending => continue ,
162
- } ;
163
- }
164
- }
165
- }
0 commit comments