File tree 2 files changed +7
-23
lines changed
library/std/src/sync/mpmc
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> {
319
319
) -> Result < ( ) , SendTimeoutError < T > > {
320
320
let token = & mut Token :: default ( ) ;
321
321
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 ) ;
335
326
}
336
327
337
328
if let Some ( d) = deadline {
@@ -379,6 +370,7 @@ impl<T> Channel<T> {
379
370
pub ( crate ) fn recv ( & self , deadline : Option < Instant > ) -> Result < T , RecvTimeoutError > {
380
371
let token = & mut Token :: default ( ) ;
381
372
loop {
373
+ // Try receiving a message.
382
374
if self . start_recv ( token) {
383
375
let res = unsafe { self . read ( token) } ;
384
376
return res. map_err ( |_| RecvTimeoutError :: Disconnected ) ;
Original file line number Diff line number Diff line change @@ -105,10 +105,8 @@ impl Backoff {
105
105
106
106
/// Backs off using lightweight spinning.
107
107
///
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.
112
110
#[ inline]
113
111
pub fn spin_light ( & self ) {
114
112
let step = self . step . get ( ) . min ( SPIN_LIMIT ) ;
@@ -134,10 +132,4 @@ impl Backoff {
134
132
135
133
self . step . set ( self . step . get ( ) + 1 ) ;
136
134
}
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
- }
143
135
}
You can’t perform that action at this time.
0 commit comments