vxx2 / vlib / v / checker / tests / shared_param_err.vv
29 lines · 25 sloc · 261 bytes · 638f0f69eda924c1478902a583703bae56e6803a
Raw
1struct St {
2mut:
3 x int
4 // data to be shared
5}
6
7fn (shared b St) g(shared c St) {
8 lock b {
9 b.x = 100
10 }
11}
12
13fn foo(shared b St) {
14 lock b {
15 b.x = 101
16 }
17}
18
19fn main() {
20 shared a := St{
21 x: 10
22 }
23 spawn a.g(a)
24 spawn foo(a)
25
26 rlock a {
27 println(a.x)
28 }
29}
30