summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/bld.sub1
-rw-r--r--lib/thread/ncpu+plan9.myr12
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/thread/bld.sub b/lib/thread/bld.sub
index c99ed89..b873e2e 100644
--- a/lib/thread/bld.sub
+++ b/lib/thread/bld.sub
@@ -25,6 +25,7 @@ lib thread =
#condvar+plan9.myr
mutex+plan9.myr
spawn+plan9.myr
+ ncpu+plan9.myr
atomic-impl+plan9-x64.s
# openbsd impl of thread primitives
diff --git a/lib/thread/ncpu+plan9.myr b/lib/thread/ncpu+plan9.myr
new file mode 100644
index 0000000..25d09cb
--- /dev/null
+++ b/lib/thread/ncpu+plan9.myr
@@ -0,0 +1,12 @@
+use std
+
+pkg thread =
+ const ncpu : (-> int)
+;;
+
+const ncpu = {
+ match std.intparse(std.getenvv("NPROC", ""))
+ | `std.Some n: -> n
+ | `std.None: -> 1
+ ;;
+}