mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
sync: close channels atomically only once (#9645)
This commit is contained in:
parent
e6a67e7172
commit
78e3bb748b
@ -138,7 +138,10 @@ fn new_channel_st(n u32, st u32) &Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut ch Channel) close() {
|
pub fn (mut ch Channel) close() {
|
||||||
C.atomic_store_u16(&ch.closed, 1)
|
open_val := u16(0)
|
||||||
|
if !C.atomic_compare_exchange_strong_u16(&ch.closed, &open_val, 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
mut nulladr := voidptr(0)
|
mut nulladr := voidptr(0)
|
||||||
for !C.atomic_compare_exchange_weak_ptr(&ch.adr_written, &nulladr, voidptr(-1)) {
|
for !C.atomic_compare_exchange_weak_ptr(&ch.adr_written, &nulladr, voidptr(-1)) {
|
||||||
nulladr = voidptr(0)
|
nulladr = voidptr(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user