v / vlib / builtin
Raw file | 32 loc (27 sloc) | 1.1 KB | Latest commit hash 7443179cc
1module builtin
2
3// ChanState describes the result of an attempted channel transaction.
4pub enum ChanState {
5 success
6 not_ready // push()/pop() would have to wait, but no_block was requested
7 closed
8}
9
10/*
11The following methods are only stubs.
12The 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.
18pub 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.
23pub 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.
30pub fn (ch chan) try_push(obj voidptr) ChanState {
31 return .success
32}