@@ -120,7 +120,7 @@ pub trait Handler: Send + Iterator<Item = Action<Self::Listener, Self::Transport
120
120
/// connections, database connections etc are all fall into this category.
121
121
type Transport : Resource ;
122
122
123
- /// A command which may be sent to the [`Handler`] from outside of the [`Reactor`], including
123
+ /// A command which may be sent to the [`Handler`] from outside the [`Reactor`], including
124
124
/// other threads.
125
125
///
126
126
/// The handler object is owned by the reactor runtime and executes always in the context of the
@@ -148,6 +148,7 @@ pub trait Handler: Send + Iterator<Item = Action<Self::Listener, Self::Transport
148
148
id : ResourceId ,
149
149
event : <Self :: Listener as Resource >:: Event ,
150
150
time : Timestamp ,
151
+ sender : Controller < Self :: Command , impl WakerSend > ,
151
152
) ;
152
153
153
154
/// Method called by the reactor upon I/O event on a transport resource.
@@ -156,6 +157,7 @@ pub trait Handler: Send + Iterator<Item = Action<Self::Listener, Self::Transport
156
157
id : ResourceId ,
157
158
event : <Self :: Transport as Resource >:: Event ,
158
159
time : Timestamp ,
160
+ sender : Controller < Self :: Command , impl WakerSend > ,
159
161
) ;
160
162
161
163
/// Method called by the reactor when a given resource was successfully registered and provided
@@ -528,10 +530,11 @@ impl<H: Handler, P: Poll> Runtime<H, P> {
528
530
#[ cfg( feature = "log" ) ]
529
531
log:: trace!( target: "reactor" , "Got `{io}` event from listener {id}" ) ;
530
532
533
+ let sender = self . controller ( ) ;
531
534
let listener = self . listeners . get_mut ( & id) . expect ( "resource disappeared" ) ;
532
535
for io in io {
533
536
if let Some ( event) = listener. handle_io ( io) {
534
- self . service . handle_listener_event ( id, event, time) ;
537
+ self . service . handle_listener_event ( id, event, time, sender . clone ( ) ) ;
535
538
}
536
539
}
537
540
}
@@ -549,10 +552,12 @@ impl<H: Handler, P: Poll> Runtime<H, P> {
549
552
#[ cfg( feature = "log" ) ]
550
553
log:: trace!( target: "reactor" , "Got `{io}` event from transport {id}" ) ;
551
554
555
+ let sender = self . controller ( ) ;
552
556
let transport = self . transports . get_mut ( & id) . expect ( "resource disappeared" ) ;
553
557
for io in io {
554
558
if let Some ( event) = transport. handle_io ( io) {
555
- self . service . handle_transport_event ( id, event, time) ;
559
+ let sender = sender. clone ( ) ;
560
+ self . service . handle_transport_event ( id, event, time, sender) ;
556
561
}
557
562
}
558
563
}
@@ -790,6 +795,7 @@ mod test {
790
795
_d : ResourceId ,
791
796
_event : <Self :: Listener as Resource >:: Event ,
792
797
_time : Timestamp ,
798
+ _sender : Controller < Cmd , impl WakerSend > ,
793
799
) {
794
800
unreachable ! ( )
795
801
}
@@ -798,6 +804,7 @@ mod test {
798
804
_id : ResourceId ,
799
805
_event : <Self :: Transport as Resource >:: Event ,
800
806
_time : Timestamp ,
807
+ _sender : Controller < Cmd , impl WakerSend > ,
801
808
) {
802
809
unreachable ! ( )
803
810
}
0 commit comments