@@ -508,7 +508,11 @@ impl<T> Peekable<T> for Port<T> {
508
508
}
509
509
}
510
510
511
- impl < T > Select for Port < T > {
511
+ // XXX: Kind of gross. A Port<T> should be selectable so you can make an array
512
+ // of them, but a &Port<T> should also be selectable so you can select2 on it
513
+ // alongside a PortOne<U> without passing the port by value in recv_ready.
514
+
515
+ impl < ' self , T > Select for & ' self Port < T > {
512
516
#[ inline]
513
517
fn optimistic_check ( & mut self ) -> bool {
514
518
do self . next . with_mut_ref |pone| { pone. optimistic_check ( ) }
@@ -526,12 +530,29 @@ impl<T> Select for Port<T> {
526
530
}
527
531
}
528
532
529
- impl < T > SelectPort < ( T , Port < T > ) > for Port < T > {
530
- fn recv_ready ( self ) -> Option < ( T , Port < T > ) > {
533
+ impl < T > Select for Port < T > {
534
+ #[ inline]
535
+ fn optimistic_check ( & mut self ) -> bool {
536
+ ( & * self ) . optimistic_check ( )
537
+ }
538
+
539
+ #[ inline]
540
+ fn block_on ( & mut self , sched : & mut Scheduler , task : BlockedTask ) -> bool {
541
+ ( & * self ) . block_on ( sched, task)
542
+ }
543
+
544
+ #[ inline]
545
+ fn unblock_from ( & mut self ) -> bool {
546
+ ( & * self ) . unblock_from ( )
547
+ }
548
+ }
549
+
550
+ impl < ' self , T > SelectPort < T > for & ' self Port < T > {
551
+ fn recv_ready ( self ) -> Option < T > {
531
552
match self . next . take ( ) . recv_ready ( ) {
532
553
Some ( StreamPayload { val, next } ) => {
533
554
self . next . put_back ( next) ;
534
- Some ( ( val, self ) )
555
+ Some ( val)
535
556
}
536
557
None => None
537
558
}
0 commit comments