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

all: add builtin channel type chan elem_type (#6126)

This commit is contained in:
Uwe Krüger
2020-08-14 21:18:42 +02:00
committed by GitHub
parent 75212f9fab
commit 9602a25a0b
13 changed files with 279 additions and 6 deletions

View File

@@ -111,6 +111,10 @@ pub:
pub fn new_channel<T>(n u32) &Channel {
st := sizeof(T)
return new_channel_st(n, st)
}
fn new_channel_st(n u32, st u32) &Channel {
return &Channel{
writesem: new_semaphore_init(if n > 0 { n + 1 } else { 1 })
readsem: new_semaphore_init(if n > 0 { u32(0) } else { 1 })