File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 1beb1f491fdd2d05ca2c05edc966535064c98cf4
2
+ refs/heads/master: c0874dbd21c89854c68e8db7201f5557ab5e6259
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Original file line number Diff line number Diff line change @@ -877,6 +877,9 @@ trait channel<T: send> {
877
877
878
878
/// Sends a message.
879
879
fn send ( +x : T ) ;
880
+
881
+ /// Sends a message, or report if the receiver has closed the connection.
882
+ fn try_send ( +x : T ) -> bool ;
880
883
}
881
884
882
885
/// A trait for things that can receive multiple messages.
@@ -931,6 +934,18 @@ impl chan<T: send> of channel<T> for chan<T> {
931
934
self . endp = some (
932
935
streamp:: client:: data ( unwrap ( endp) , x) )
933
936
}
937
+
938
+ fn try_send ( +x : T ) -> bool {
939
+ let mut endp = none;
940
+ endp <-> self . endp ;
941
+ match move streamp:: client:: try_data ( unwrap ( endp) , x) {
942
+ some( next) => {
943
+ self . endp = some ( move_it ! ( next) ) ;
944
+ true
945
+ }
946
+ none => false
947
+ }
948
+ }
934
949
}
935
950
936
951
impl port < T : send > of recv < T > for port < T > {
@@ -1047,6 +1062,15 @@ impl chan<T: send> of channel<T> for shared_chan<T> {
1047
1062
chan. send ( option:: unwrap ( x) )
1048
1063
}
1049
1064
}
1065
+
1066
+ fn try_send ( +x : T ) -> bool {
1067
+ let mut xx = some ( x) ;
1068
+ do self. with |chan| {
1069
+ let mut x = none;
1070
+ x <-> xx;
1071
+ chan. try_send ( option:: unwrap ( x) )
1072
+ }
1073
+ }
1050
1074
}
1051
1075
1052
1076
/// Converts a `chan` into a `shared_chan`.
You can’t perform that action at this time.
0 commit comments