File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,33 @@ mod fifo {
314
314
}
315
315
}
316
316
317
+ // https://github.com/golang/go/blob/master/test/chan/goroutines.go
318
+ mod goroutines {
319
+ use super :: * ;
320
+
321
+ fn f ( left : Chan < i32 > , right : Chan < i32 > ) {
322
+ left. send ( right. recv ( ) . unwrap ( ) ) ;
323
+ }
324
+
325
+ #[ test]
326
+ fn main ( ) {
327
+ let n = 10_000i32 ;
328
+
329
+ let leftmost = make :: < i32 > ( 0 ) ;
330
+ let mut right = leftmost. clone ( ) ;
331
+ let mut left = leftmost. clone ( ) ;
332
+
333
+ for _ in 0 ..n {
334
+ right = make :: < i32 > ( 0 ) ;
335
+ go ! ( left, right, f( left, right) ) ;
336
+ left = right. clone ( ) ;
337
+ }
338
+
339
+ go ! ( right, right. send( 1 ) ) ;
340
+ leftmost. recv ( ) . unwrap ( ) ;
341
+ }
342
+ }
343
+
317
344
// https://github.com/golang/go/blob/master/test/chan/nonblock.go
318
345
mod nonblock {
319
346
use super :: * ;
You can’t perform that action at this time.
0 commit comments