sync: close channels atomically only once (#9645)
parent
e6a67e7172
commit
78e3bb748b
|
@ -138,7 +138,10 @@ fn new_channel_st(n u32, st u32) &Channel {
|
|||
}
|
||||
|
||||
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)
|
||||
for !C.atomic_compare_exchange_weak_ptr(&ch.adr_written, &nulladr, voidptr(-1)) {
|
||||
nulladr = voidptr(0)
|
||||
|
|
Loading…
Reference in New Issue