v2 / vlib / v / tests / concurrency / chan_try_push_int_test.v
15 lines · 14 sloc · 196 bytes · 36ca628c59e019d11b55a476690b2f37a81a1d67
Raw
1struct Foo {
2mut:
3 value int = 123
4}
5
6fn test_main() {
7 shared m := Foo{}
8 ch := chan int{cap: 1}
9 ch.try_push(rlock m {
10 m.value
11 })
12 mut tmp := int(0)
13 ch.try_pop(mut tmp)
14 assert tmp == 123
15}
16