mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
27 lines
326 B
V
27 lines
326 B
V
struct Aa {
|
|
mut:
|
|
b []int
|
|
}
|
|
|
|
fn append_ok(shared a Aa, new_b int) {
|
|
lock a {
|
|
a.b << new_b
|
|
}
|
|
}
|
|
|
|
fn (shared a Aa) append_fails(new_b int) {
|
|
lock a {
|
|
a.b << new_b
|
|
}
|
|
}
|
|
|
|
fn test_shared_struct_method_call() {
|
|
shared a := Aa{}
|
|
append_ok(shared a, 1)
|
|
a.append_fails(2)
|
|
rlock a {
|
|
println(a.b)
|
|
assert a.b == [1, 2]
|
|
}
|
|
}
|