@shd101wyy/yo 0.0.33 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/out/cjs/index.cjs +253 -235
- package/out/cjs/yo-cli.cjs +314 -296
- package/out/esm/index.mjs +255 -237
- package/out/types/src/codegen/parallelism/runtime.d.ts +1 -1
- package/out/types/src/codegen/utils/index.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/thread.yo +4 -3
- package/std/worker.yo +4 -2
package/package.json
CHANGED
package/std/thread.yo
CHANGED
|
@@ -8,7 +8,7 @@ extern "Yo",
|
|
|
8
8
|
// Low-level runtime types and functions for Thread
|
|
9
9
|
extern "Yo",
|
|
10
10
|
__yo_thread_t : Type,
|
|
11
|
-
__yo_thread_spawn : (fn(cb : Impl(Fn() -> unit, Send)) -> __yo_thread_t),
|
|
11
|
+
__yo_thread_spawn : (fn(cb : Impl(Fn(using(io : IO)) -> unit, Send)) -> __yo_thread_t),
|
|
12
12
|
__yo_thread_join : (fn(t : __yo_thread_t) -> unit)
|
|
13
13
|
;
|
|
14
14
|
|
|
@@ -17,8 +17,9 @@ Thread :: struct(
|
|
|
17
17
|
handle : __yo_thread_t
|
|
18
18
|
);
|
|
19
19
|
impl(Thread,
|
|
20
|
-
// Spawn a new OS thread running the given closure
|
|
21
|
-
|
|
20
|
+
// Spawn a new OS thread running the given closure.
|
|
21
|
+
// The closure receives its own per-thread IO event loop.
|
|
22
|
+
spawn : (fn(cb : Impl(Fn(using(io : IO)) -> unit, Send)) -> Self)({
|
|
22
23
|
raw := __yo_thread_spawn(cb);
|
|
23
24
|
Self(raw)
|
|
24
25
|
}),
|
package/std/worker.yo
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
// Thread-per-core: By default, one worker thread per CPU core.
|
|
8
8
|
// Thread affinity: Each task runs on a specific worker thread.
|
|
9
9
|
// Thread-local GC: Each worker thread has its own GC heap.
|
|
10
|
+
// Per-thread IO: Each worker thread has its own async event loop, shared by all tasks on that thread.
|
|
10
11
|
|
|
11
12
|
extern "Yo",
|
|
12
|
-
__yo_worker_spawn : (fn(cb : Impl(Fn() -> unit, Send)) -> unit),
|
|
13
|
+
__yo_worker_spawn : (fn(cb : Impl(Fn(using(io : IO)) -> unit, Send)) -> unit),
|
|
13
14
|
__yo_worker_get_num_threads : (fn() -> usize),
|
|
14
15
|
__yo_worker_set_num_threads : (fn(num: usize) -> unit)
|
|
15
16
|
;
|
|
@@ -17,7 +18,8 @@ extern "Yo",
|
|
|
17
18
|
// Spawn a task on the thread pool.
|
|
18
19
|
// Returns immediately, task runs in background.
|
|
19
20
|
// Tasks are distributed round-robin to worker threads.
|
|
20
|
-
|
|
21
|
+
// The closure receives the worker thread's IO event loop.
|
|
22
|
+
spawn :: (fn(cb : Impl(Fn(using(io : IO)) -> unit, Send)) -> unit)({
|
|
21
23
|
__yo_worker_spawn(cb);
|
|
22
24
|
});
|
|
23
25
|
|