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

v.gen.c,v.markused: fix println(ch) when ch is a channel

This commit is contained in:
Delyan Angelov
2021-06-01 13:37:37 +03:00
parent 0afeba5588
commit 5cb2683e97
4 changed files with 62 additions and 1 deletions

View File

@ -136,6 +136,10 @@ fn new_channel_st(n u32, st u32) &Channel {
return ch
}
pub fn (ch &Channel) auto_str(typename string) string {
return 'chan $typename{cap: $ch.cap, closed: $ch.closed}'
}
pub fn (mut ch Channel) close() {
open_val := u16(0)
if !C.atomic_compare_exchange_strong_u16(&ch.closed, &open_val, 1) {