1 | module sync |
2 | |
3 | pub struct Channel { |
4 | arr array |
5 | } |
6 | |
7 | pub fn new_channel[T](n u32) &Channel { |
8 | return &Channel{arr, new_array()} |
9 | } |
10 | |
11 | pub fn (mut ch Channel) close() {} |
12 | |
13 | pub fn (mut ch Channel) push(src voidptr) { |
14 | #array_push(ch.val.arr,src) |
15 | } |
16 | |
17 | pub fn (ch Channel) len() int { |
18 | return ch.arr.len |
19 | } |
20 | |
21 | pub fn (ch Channel) closed() bool { |
22 | return false |
23 | } |
24 | |
25 | pub fn (mut ch Channel) pop(dest voidptr) { |
26 | #dest.val = array_pop(ch.val.arr) |
27 | } |