@@ -171,7 +171,7 @@ enum Timeout {
171
171
/// Successful receive operations will have to be followed up by `channel::read()` and successful
172
172
/// send operations by `channel::write()`.
173
173
fn run_select (
174
- handles : & mut [ ( & SelectHandle , usize , * const u8 ) ] ,
174
+ handles : & mut [ ( & dyn SelectHandle , usize , * const u8 ) ] ,
175
175
timeout : Timeout ,
176
176
) -> Option < ( Token , usize , * const u8 ) > {
177
177
if handles. is_empty ( ) {
@@ -220,7 +220,7 @@ fn run_select(
220
220
registered_count += 1 ;
221
221
222
222
// If registration returns `false`, that means the operation has just become ready.
223
- if handle. register ( Operation :: hook :: < & SelectHandle > ( handle) , cx) {
223
+ if handle. register ( Operation :: hook :: < & dyn SelectHandle > ( handle) , cx) {
224
224
// Try aborting select.
225
225
sel = match cx. try_select ( Selected :: Aborted ) {
226
226
Ok ( ( ) ) => {
@@ -259,7 +259,7 @@ fn run_select(
259
259
260
260
// Unregister all registered operations.
261
261
for ( handle, _, _) in handles. iter_mut ( ) . take ( registered_count) {
262
- handle. unregister ( Operation :: hook :: < & SelectHandle > ( handle) ) ;
262
+ handle. unregister ( Operation :: hook :: < & dyn SelectHandle > ( handle) ) ;
263
263
}
264
264
265
265
match sel {
@@ -279,7 +279,8 @@ fn run_select(
279
279
// Find the selected operation.
280
280
for ( handle, i, ptr) in handles. iter_mut ( ) {
281
281
// Is this the selected operation?
282
- if sel == Selected :: Operation ( Operation :: hook :: < & SelectHandle > ( handle) ) {
282
+ if sel == Selected :: Operation ( Operation :: hook :: < & dyn SelectHandle > ( handle) )
283
+ {
283
284
// Try selecting this operation.
284
285
if handle. accept ( & mut token, cx) {
285
286
return Some ( ( * i, * ptr) ) ;
@@ -317,7 +318,10 @@ fn run_select(
317
318
}
318
319
319
320
/// Runs until one of the operations becomes ready, potentially blocking the current thread.
320
- fn run_ready ( handles : & mut [ ( & SelectHandle , usize , * const u8 ) ] , timeout : Timeout ) -> Option < usize > {
321
+ fn run_ready (
322
+ handles : & mut [ ( & dyn SelectHandle , usize , * const u8 ) ] ,
323
+ timeout : Timeout ,
324
+ ) -> Option < usize > {
321
325
if handles. is_empty ( ) {
322
326
// Wait until the timeout and return.
323
327
match timeout {
@@ -372,7 +376,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
372
376
// Begin watching all operations.
373
377
for ( handle, _, _) in handles. iter_mut ( ) {
374
378
registered_count += 1 ;
375
- let oper = Operation :: hook :: < & SelectHandle > ( handle) ;
379
+ let oper = Operation :: hook :: < & dyn SelectHandle > ( handle) ;
376
380
377
381
// If registration returns `false`, that means the operation has just become ready.
378
382
if handle. watch ( oper, cx) {
@@ -410,7 +414,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
410
414
411
415
// Unwatch all operations.
412
416
for ( handle, _, _) in handles. iter_mut ( ) . take ( registered_count) {
413
- handle. unwatch ( Operation :: hook :: < & SelectHandle > ( handle) ) ;
417
+ handle. unwatch ( Operation :: hook :: < & dyn SelectHandle > ( handle) ) ;
414
418
}
415
419
416
420
match sel {
@@ -419,7 +423,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
419
423
Selected :: Disconnected => { }
420
424
Selected :: Operation ( _) => {
421
425
for ( handle, i, _) in handles. iter_mut ( ) {
422
- let oper = Operation :: hook :: < & SelectHandle > ( handle) ;
426
+ let oper = Operation :: hook :: < & dyn SelectHandle > ( handle) ;
423
427
if sel == Selected :: Operation ( oper) {
424
428
return Some ( * i) ;
425
429
}
@@ -440,7 +444,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
440
444
/// Attempts to select one of the operations without blocking.
441
445
#[ inline]
442
446
pub fn try_select < ' a > (
443
- handles : & mut [ ( & ' a SelectHandle , usize , * const u8 ) ] ,
447
+ handles : & mut [ ( & ' a dyn SelectHandle , usize , * const u8 ) ] ,
444
448
) -> Result < SelectedOperation < ' a > , TrySelectError > {
445
449
match run_select ( handles, Timeout :: Now ) {
446
450
None => Err ( TrySelectError ) ,
@@ -455,7 +459,9 @@ pub fn try_select<'a>(
455
459
456
460
/// Blocks until one of the operations becomes ready and selects it.
457
461
#[ inline]
458
- pub fn select < ' a > ( handles : & mut [ ( & ' a SelectHandle , usize , * const u8 ) ] ) -> SelectedOperation < ' a > {
462
+ pub fn select < ' a > (
463
+ handles : & mut [ ( & ' a dyn SelectHandle , usize , * const u8 ) ] ,
464
+ ) -> SelectedOperation < ' a > {
459
465
if handles. is_empty ( ) {
460
466
panic ! ( "no operations have been added to `Select`" ) ;
461
467
}
@@ -472,7 +478,7 @@ pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> Selec
472
478
/// Blocks for a limited time until one of the operations becomes ready and selects it.
473
479
#[ inline]
474
480
pub fn select_timeout < ' a > (
475
- handles : & mut [ ( & ' a SelectHandle , usize , * const u8 ) ] ,
481
+ handles : & mut [ ( & ' a dyn SelectHandle , usize , * const u8 ) ] ,
476
482
timeout : Duration ,
477
483
) -> Result < SelectedOperation < ' a > , SelectTimeoutError > {
478
484
let timeout = Timeout :: At ( Instant :: now ( ) + timeout) ;
@@ -573,7 +579,7 @@ pub fn select_timeout<'a>(
573
579
/// [`ready_timeout`]: struct.Select.html#method.ready_timeout
574
580
pub struct Select < ' a > {
575
581
/// A list of senders and receivers participating in selection.
576
- handles : Vec < ( & ' a SelectHandle , usize , * const u8 ) > ,
582
+ handles : Vec < ( & ' a dyn SelectHandle , usize , * const u8 ) > ,
577
583
578
584
/// The next index to assign to an operation.
579
585
next_index : usize ,
0 commit comments