1 | module builtin |
2 | |
3 | // ChanState describes the result of an attempted channel transaction. |
4 | pub enum ChanState { |
5 | success |
6 | not_ready // push()/pop() would have to wait, but no_block was requested |
7 | closed |
8 | } |
9 | |
10 | /* |
11 | The following methods are only stubs. |
12 | The real implementation is in `vlib/sync/channels.v` |
13 | */ |
14 | |
15 | // close closes the channel for further push transactions. |
16 | // closed channels cannot be pushed to, however they can be popped |
17 | // from as long as there is still objects available in the channel buffer. |
18 | pub fn (ch chan) close() {} |
19 | |
20 | // try_pop returns `ChanState.success` if an object is popped from the channel. |
21 | // try_pop effectively pops from the channel without waiting for objects to become available. |
22 | // Both the test and pop transaction is done atomically. |
23 | pub fn (ch chan) try_pop(obj voidptr) ChanState { |
24 | return .success |
25 | } |
26 | |
27 | // try_push returns `ChanState.success` if the object is pushed to the channel. |
28 | // try_push effectively both push and test if the transaction `ch <- a` succeeded. |
29 | // Both the test and push transaction is done atomically. |
30 | pub fn (ch chan) try_push(obj voidptr) ChanState { |
31 | return .success |
32 | } |