File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
branches/try2/src/libstd/sync Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: 0439162d597d4abfebf93096e71ff45242efe6f0
8
+ refs/heads/try2: 01dc27a219435714ec38d0a2ddd1594d96e4da72
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ impl<A:Send> Future<A> {
132
132
let ( tx, rx) = channel ( ) ;
133
133
134
134
spawn ( proc ( ) {
135
- tx. send ( blk ( ) ) ;
135
+ // Don't fail if the other end has hung up
136
+ let _ = tx. send_opt ( blk ( ) ) ;
136
137
} ) ;
137
138
138
139
Future :: from_receiver ( rx)
@@ -144,6 +145,7 @@ mod test {
144
145
use prelude:: * ;
145
146
use sync:: Future ;
146
147
use task;
148
+ use comm:: { channel, Sender } ;
147
149
148
150
#[ test]
149
151
fn test_from_value ( ) {
@@ -206,4 +208,28 @@ mod test {
206
208
assert_eq ! ( actual, expected) ;
207
209
} ) ;
208
210
}
211
+
212
+ #[ test]
213
+ fn test_dropped_future_doesnt_fail ( ) {
214
+ struct Bomb ( Sender < bool > ) ;
215
+
216
+ local_data_key ! ( LOCAL : Bomb )
217
+
218
+ impl Drop for Bomb {
219
+ fn drop ( & mut self ) {
220
+ let Bomb ( ref tx) = * self ;
221
+ tx. send ( task:: failing ( ) ) ;
222
+ }
223
+ }
224
+
225
+ // Spawn a future, but drop it immediately. When we receive the result
226
+ // later on, we should never view the task as having failed.
227
+ let ( tx, rx) = channel ( ) ;
228
+ drop ( Future :: spawn ( proc ( ) {
229
+ LOCAL . replace ( Some ( Bomb ( tx) ) ) ;
230
+ } ) ) ;
231
+
232
+ // Make sure the future didn't fail the task.
233
+ assert ! ( !rx. recv( ) ) ;
234
+ }
209
235
}
You can’t perform that action at this time.
0 commit comments