aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/context/empty.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/context/empty.v
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/context/empty.v')
-rw-r--r--v_windows/v/vlib/context/empty.v42
1 files changed, 42 insertions, 0 deletions
diff --git a/v_windows/v/vlib/context/empty.v b/v_windows/v/vlib/context/empty.v
new file mode 100644
index 0000000..335369a
--- /dev/null
+++ b/v_windows/v/vlib/context/empty.v
@@ -0,0 +1,42 @@
+// This module defines the Context type, which carries deadlines, cancellation signals,
+// and other request-scoped values across API boundaries and between processes.
+// Based off: https://github.com/golang/go/tree/master/src/context
+// Last commit: https://github.com/golang/go/commit/52bf14e0e8bdcd73f1ddfb0c4a1d0200097d3ba2
+module context
+
+import time
+
+// An EmptyContext is never canceled, has no values, and has no deadline. It is not
+// struct{}, since vars of this type must have distinct addresses.
+pub type EmptyContext = int
+
+pub fn (ctx EmptyContext) deadline() ?time.Time {
+ return none
+}
+
+pub fn (ctx EmptyContext) done() chan int {
+ ch := chan int{}
+ defer {
+ ch.close()
+ }
+ return ch
+}
+
+pub fn (ctx EmptyContext) err() IError {
+ // TODO: Change this to `none`
+ return none_
+}
+
+pub fn (ctx EmptyContext) value(key string) ?voidptr {
+ return none
+}
+
+pub fn (ctx EmptyContext) str() string {
+ if ctx == background {
+ return 'context.Background'
+ }
+ if ctx == todo {
+ return 'context.TODO'
+ }
+ return 'unknown empty Context'
+}