@@ -622,7 +622,12 @@ impl<A: Actor> ActorHandle<A> {
622
622
623
623
/// Send a message to the actor. Messages sent through the handle
624
624
/// are always queued in process, and do not require serialization.
625
- pub fn send < M : Message > ( & self , message : M ) -> Result < ( ) , MailboxSenderError >
625
+ pub fn send < M : Message > (
626
+ & self ,
627
+ // TODO(pzhang): use this parameter to generate sequence number.
628
+ _cx : & impl context:: Actor ,
629
+ message : M ,
630
+ ) -> Result < ( ) , MailboxSenderError >
626
631
where
627
632
A : Handler < M > ,
628
633
{
@@ -753,10 +758,10 @@ mod tests {
753
758
#[ tokio:: test]
754
759
async fn test_server_basic ( ) {
755
760
let proc = Proc :: local ( ) ;
756
- let client = proc. attach ( "client" ) . unwrap ( ) ;
761
+ let ( client, _ ) = proc. instance ( "client" ) . unwrap ( ) ;
757
762
let ( tx, mut rx) = client. open_port ( ) ;
758
763
let handle = proc. spawn :: < EchoActor > ( "echo" , tx. bind ( ) ) . await . unwrap ( ) ;
759
- handle. send ( 123u64 ) . unwrap ( ) ;
764
+ handle. send ( & client , 123u64 ) . unwrap ( ) ;
760
765
handle. drain_and_stop ( ) . unwrap ( ) ;
761
766
handle. await ;
762
767
@@ -766,7 +771,7 @@ mod tests {
766
771
#[ tokio:: test]
767
772
async fn test_ping_pong ( ) {
768
773
let proc = Proc :: local ( ) ;
769
- let client = proc. attach ( "client" ) . unwrap ( ) ;
774
+ let ( client, _ ) = proc. instance ( "client" ) . unwrap ( ) ;
770
775
let ( undeliverable_msg_tx, _) = client. open_port ( ) ;
771
776
772
777
let ping_pong_actor_params =
@@ -783,7 +788,10 @@ mod tests {
783
788
let ( local_port, local_receiver) = client. open_once_port ( ) ;
784
789
785
790
ping_handle
786
- . send ( PingPongMessage ( 10 , pong_handle. bind ( ) , local_port. bind ( ) ) )
791
+ . send (
792
+ & client,
793
+ PingPongMessage ( 10 , pong_handle. bind ( ) , local_port. bind ( ) ) ,
794
+ )
787
795
. unwrap ( ) ;
788
796
789
797
assert ! ( local_receiver. recv( ) . await . unwrap( ) ) ;
@@ -792,7 +800,7 @@ mod tests {
792
800
#[ tokio:: test]
793
801
async fn test_ping_pong_on_handler_error ( ) {
794
802
let proc = Proc :: local ( ) ;
795
- let client = proc. attach ( "client" ) . unwrap ( ) ;
803
+ let ( client, _ ) = proc. instance ( "client" ) . unwrap ( ) ;
796
804
let ( undeliverable_msg_tx, _) = client. open_port ( ) ;
797
805
798
806
// Need to set a supervison coordinator for this Proc because there will
@@ -814,11 +822,14 @@ mod tests {
814
822
let ( local_port, local_receiver) = client. open_once_port ( ) ;
815
823
816
824
ping_handle
817
- . send ( PingPongMessage (
818
- error_ttl + 1 , // will encounter an error at TTL=66
819
- pong_handle. bind ( ) ,
820
- local_port. bind ( ) ,
821
- ) )
825
+ . send (
826
+ & client,
827
+ PingPongMessage (
828
+ error_ttl + 1 , // will encounter an error at TTL=66
829
+ pong_handle. bind ( ) ,
830
+ local_port. bind ( ) ,
831
+ ) ,
832
+ )
822
833
. unwrap ( ) ;
823
834
824
835
// TODO: Fix this receiver hanging issue in T200423722.
@@ -861,10 +872,10 @@ mod tests {
861
872
async fn test_init ( ) {
862
873
let proc = Proc :: local ( ) ;
863
874
let handle = proc. spawn :: < InitActor > ( "init" , ( ) ) . await . unwrap ( ) ;
864
- let client = proc. attach ( "client" ) . unwrap ( ) ;
875
+ let ( client, _ ) = proc. instance ( "client" ) . unwrap ( ) ;
865
876
866
877
let ( port, receiver) = client. open_once_port ( ) ;
867
- handle. send ( port) . unwrap ( ) ;
878
+ handle. send ( & client , port) . unwrap ( ) ;
868
879
assert ! ( receiver. recv( ) . await . unwrap( ) ) ;
869
880
870
881
handle. drain_and_stop ( ) . unwrap ( ) ;
@@ -946,12 +957,12 @@ mod tests {
946
957
M : RemoteMessage ,
947
958
MultiActor : Handler < M > ,
948
959
{
949
- self . handle . send ( message) . unwrap ( )
960
+ self . handle . send ( & self . client , message) . unwrap ( )
950
961
}
951
962
952
963
async fn sync ( & self ) {
953
964
let ( port, done) = self . client . open_once_port :: < bool > ( ) ;
954
- self . handle . send ( port) . unwrap ( ) ;
965
+ self . handle . send ( & self . client , port) . unwrap ( ) ;
955
966
assert ! ( done. recv( ) . await . unwrap( ) ) ;
956
967
}
957
968
0 commit comments