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 2
2
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
- refs/heads/try: 1beb1f491fdd2d05ca2c05edc966535064c98cf4
5
+ refs/heads/try: c0874dbd21c89854c68e8db7201f5557ab5e6259
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
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