File tree Expand file tree Collapse file tree 2 files changed +7
-23
lines changed
library/std/src/sync/mpmc Expand file tree Collapse file tree 2 files changed +7
-23
lines changed Original file line number Diff line number Diff line change @@ -319,19 +319,10 @@ impl<T> Channel<T> {
319319 ) -> Result < ( ) , SendTimeoutError < T > > {
320320 let token = & mut Token :: default ( ) ;
321321 loop {
322- // Try sending a message several times.
323- let backoff = Backoff :: new ( ) ;
324- loop {
325- if self . start_send ( token) {
326- let res = unsafe { self . write ( token, msg) } ;
327- return res. map_err ( SendTimeoutError :: Disconnected ) ;
328- }
329-
330- if backoff. is_completed ( ) {
331- break ;
332- } else {
333- backoff. spin_light ( ) ;
334- }
322+ // Try sending a message.
323+ if self . start_send ( token) {
324+ let res = unsafe { self . write ( token, msg) } ;
325+ return res. map_err ( SendTimeoutError :: Disconnected ) ;
335326 }
336327
337328 if let Some ( d) = deadline {
@@ -379,6 +370,7 @@ impl<T> Channel<T> {
379370 pub ( crate ) fn recv ( & self , deadline : Option < Instant > ) -> Result < T , RecvTimeoutError > {
380371 let token = & mut Token :: default ( ) ;
381372 loop {
373+ // Try receiving a message.
382374 if self . start_recv ( token) {
383375 let res = unsafe { self . read ( token) } ;
384376 return res. map_err ( |_| RecvTimeoutError :: Disconnected ) ;
Original file line number Diff line number Diff line change @@ -105,10 +105,8 @@ impl Backoff {
105105
106106 /// Backs off using lightweight spinning.
107107 ///
108- /// This method should be used for:
109- /// - Retrying an operation because another thread made progress. i.e. on CAS failure.
110- /// - Waiting for an operation to complete by spinning optimistically for a few iterations
111- /// before falling back to parking the thread (see `Backoff::is_completed`).
108+ /// This method should be used for retrying an operation because another thread made
109+ /// progress. i.e. on CAS failure.
112110 #[ inline]
113111 pub fn spin_light ( & self ) {
114112 let step = self . step . get ( ) . min ( SPIN_LIMIT ) ;
@@ -134,10 +132,4 @@ impl Backoff {
134132
135133 self . step . set ( self . step . get ( ) + 1 ) ;
136134 }
137-
138- /// Returns `true` if quadratic backoff has completed and parking the thread is advised.
139- #[ inline]
140- pub fn is_completed ( & self ) -> bool {
141- self . step . get ( ) > SPIN_LIMIT
142- }
143135}
You can’t perform that action at this time.
0 commit comments