1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sync/channels: expose ch.closed as bool pseudo attribute (#8244)

This commit is contained in:
Uwe Krüger
2021-01-22 08:37:29 +01:00
committed by GitHub
parent 820e684313
commit 925ffd76f4
5 changed files with 50 additions and 43 deletions

View File

@ -162,6 +162,11 @@ pub fn (mut ch Channel) len() int {
return int(C.atomic_load_u32(&ch.read_avail))
}
[inline]
pub fn (mut ch Channel) closed() bool {
return C.atomic_load_u16(&ch.closed) != 0
}
[inline]
pub fn (mut ch Channel) push(src voidptr) {
if ch.try_push_priv(src, false) == .closed {