diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/vlib/builtin/chan.v | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/old/vlib/builtin/chan.v')
-rw-r--r-- | v_windows/v/old/vlib/builtin/chan.v | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/builtin/chan.v b/v_windows/v/old/vlib/builtin/chan.v new file mode 100644 index 0000000..1692d5f --- /dev/null +++ b/v_windows/v/old/vlib/builtin/chan.v @@ -0,0 +1,32 @@ +module builtin + +// ChanState describes the result of an attempted channel transaction. +pub enum ChanState { + success + not_ready // push()/pop() would have to wait, but no_block was requested + closed +} + +/* +The following methods are only stubs. +The real implementation is in `vlib/sync/channels.v` +*/ + +// close closes the channel for further push transactions. +// closed channels cannot be pushed to, however they can be popped +// from as long as there is still objects available in the channel buffer. +pub fn (ch chan) close() {} + +// try_pop returns `ChanState.success` if an object is popped from the channel. +// try_pop effectively pops from the channel without waiting for objects to become available. +// Both the test and pop transaction is done atomically. +pub fn (ch chan) try_pop(obj voidptr) ChanState { + return .success +} + +// try_push returns `ChanState.success` if the object is pushed to the channel. +// try_push effectively both push and test if the transaction `ch <- a` succeeded. +// Both the test and push transaction is done atomically. +pub fn (ch chan) try_push(obj voidptr) ChanState { + return .success +} |