@shd101wyy/yo 0.1.28 → 0.1.30
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/.github/skills/yo-async-effects/SKILL.md +15 -15
- package/.github/skills/yo-async-effects/async-effects-recipes.md +118 -121
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +33 -13
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +1 -1
- package/.github/skills/yo-syntax/SKILL.md +2 -2
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +108 -96
- package/README.md +6 -3
- package/out/cjs/index.cjs +812 -706
- package/out/cjs/yo-cli.cjs +1023 -907
- package/out/cjs/yo-lsp.cjs +836 -730
- package/out/esm/index.mjs +757 -651
- package/out/types/src/codegen/exprs/async.d.ts +2 -0
- package/out/types/src/codegen/exprs/await.d.ts +1 -0
- package/out/types/src/codegen/exprs/closures.d.ts +4 -0
- package/out/types/src/codegen/functions/context.d.ts +6 -0
- package/out/types/src/codegen/functions/declarations.d.ts +1 -1
- package/out/types/src/doc/model.d.ts +0 -1
- package/out/types/src/env.d.ts +2 -2
- package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
- package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
- package/out/types/src/evaluator/context.d.ts +3 -1
- package/out/types/src/evaluator/exprs/{escape.d.ts → unwind.d.ts} +1 -1
- package/out/types/src/evaluator/index.d.ts +1 -1
- package/out/types/src/evaluator/memory-safety.d.ts +14 -0
- package/out/types/src/evaluator/types/flowability.d.ts +6 -0
- package/out/types/src/evaluator/types/function.d.ts +1 -2
- package/out/types/src/evaluator/utils.d.ts +0 -1
- package/out/types/src/expr-traversal.d.ts +1 -0
- package/out/types/src/expr.d.ts +9 -7
- package/out/types/src/public-safe-report.d.ts +19 -0
- package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
- package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
- package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
- package/out/types/src/tests/type-representation-pointer.test.d.ts +1 -0
- package/out/types/src/tests/unsafe-gate.test.d.ts +1 -0
- package/out/types/src/tests/unsafe-report-classify.test.d.ts +1 -0
- package/out/types/src/types/creators.d.ts +4 -6
- package/out/types/src/types/definitions.d.ts +9 -16
- package/out/types/src/types/guards.d.ts +1 -2
- package/out/types/src/types/tags.d.ts +0 -1
- package/out/types/src/types/utils.d.ts +5 -0
- package/out/types/src/unsafe-report.d.ts +29 -0
- package/out/types/src/value.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/add-pragma-for-pointer-decls.ts +134 -0
- package/scripts/add-pragma.ts +58 -0
- package/scripts/migrate-amp-method-calls.ts +186 -0
- package/scripts/migrate-clone-calls.ts +93 -0
- package/scripts/migrate-get-unwrap.ts +166 -0
- package/scripts/migrate-index-patterns.ts +210 -0
- package/scripts/migrate-index-trait.ts +142 -0
- package/scripts/migrate-iterator.ts +150 -0
- package/scripts/migrate-self-ptr.ts +220 -0
- package/scripts/migrate-skip-pragmas.ts +109 -0
- package/scripts/migrate-tostring.ts +134 -0
- package/scripts/trim-pragma.ts +130 -0
- package/scripts/wrap-extern-calls.ts +161 -0
- package/std/alg/hash.yo +3 -2
- package/std/allocator.yo +6 -5
- package/std/async.yo +2 -2
- package/std/collections/array_list.yo +59 -40
- package/std/collections/btree_map.yo +19 -18
- package/std/collections/deque.yo +9 -8
- package/std/collections/hash_map.yo +101 -13
- package/std/collections/hash_set.yo +5 -4
- package/std/collections/linked_list.yo +39 -4
- package/std/collections/ordered_map.yo +3 -3
- package/std/collections/priority_queue.yo +14 -13
- package/std/crypto/md5.yo +2 -1
- package/std/crypto/random.yo +21 -20
- package/std/crypto/sha256.yo +2 -1
- package/std/encoding/base64.yo +18 -18
- package/std/encoding/hex.yo +5 -5
- package/std/encoding/json.yo +62 -13
- package/std/encoding/punycode.yo +24 -23
- package/std/encoding/toml.yo +4 -3
- package/std/encoding/utf16.yo +3 -3
- package/std/env.yo +43 -28
- package/std/error.yo +15 -3
- package/std/fmt/display.yo +2 -2
- package/std/fmt/index.yo +6 -5
- package/std/fmt/to_string.yo +39 -38
- package/std/fmt/writer.yo +9 -8
- package/std/fs/dir.yo +61 -66
- package/std/fs/file.yo +121 -126
- package/std/fs/metadata.yo +13 -18
- package/std/fs/temp.yo +35 -30
- package/std/fs/walker.yo +14 -19
- package/std/gc.yo +1 -0
- package/std/glob.yo +7 -7
- package/std/http/client.yo +33 -36
- package/std/http/http.yo +6 -6
- package/std/http/index.yo +4 -4
- package/std/imm/list.yo +33 -0
- package/std/imm/map.yo +2 -1
- package/std/imm/set.yo +1 -0
- package/std/imm/sorted_map.yo +1 -0
- package/std/imm/sorted_set.yo +1 -0
- package/std/imm/string.yo +27 -23
- package/std/imm/vec.yo +18 -2
- package/std/io/reader.yo +2 -1
- package/std/io/writer.yo +3 -2
- package/std/libc/assert.yo +1 -0
- package/std/libc/ctype.yo +1 -0
- package/std/libc/dirent.yo +1 -0
- package/std/libc/errno.yo +1 -0
- package/std/libc/fcntl.yo +1 -0
- package/std/libc/float.yo +1 -0
- package/std/libc/limits.yo +1 -0
- package/std/libc/math.yo +1 -0
- package/std/libc/signal.yo +1 -0
- package/std/libc/stdatomic.yo +1 -0
- package/std/libc/stdint.yo +1 -0
- package/std/libc/stdio.yo +1 -0
- package/std/libc/stdlib.yo +1 -0
- package/std/libc/string.yo +1 -0
- package/std/libc/sys/stat.yo +1 -0
- package/std/libc/time.yo +1 -0
- package/std/libc/unistd.yo +1 -0
- package/std/libc/wctype.yo +1 -0
- package/std/libc/windows.yo +2 -0
- package/std/log.yo +7 -6
- package/std/net/addr.yo +6 -5
- package/std/net/dns.yo +13 -16
- package/std/net/errors.yo +9 -9
- package/std/net/tcp.yo +71 -74
- package/std/net/udp.yo +40 -43
- package/std/os/signal.yo +5 -5
- package/std/path.yo +1 -0
- package/std/prelude.yo +377 -200
- package/std/process/command.yo +57 -46
- package/std/process/index.yo +2 -1
- package/std/regex/compiler.yo +10 -9
- package/std/regex/index.yo +41 -41
- package/std/regex/match.yo +2 -2
- package/std/regex/parser.yo +31 -31
- package/std/regex/vm.yo +42 -41
- package/std/string/string.yo +95 -40
- package/std/string/string_builder.yo +9 -9
- package/std/string/unicode.yo +50 -49
- package/std/sync/channel.yo +2 -1
- package/std/sync/cond.yo +5 -4
- package/std/sync/mutex.yo +4 -3
- package/std/sys/advise.yo +1 -0
- package/std/sys/bufio/buf_reader.yo +27 -26
- package/std/sys/bufio/buf_writer.yo +22 -21
- package/std/sys/clock.yo +1 -0
- package/std/sys/copy.yo +1 -0
- package/std/sys/dir.yo +10 -9
- package/std/sys/dns.yo +6 -5
- package/std/sys/errors.yo +12 -12
- package/std/sys/events.yo +1 -0
- package/std/sys/externs.yo +38 -37
- package/std/sys/file.yo +17 -16
- package/std/sys/future.yo +4 -3
- package/std/sys/iov.yo +1 -0
- package/std/sys/mmap.yo +1 -0
- package/std/sys/path.yo +1 -0
- package/std/sys/perm.yo +2 -1
- package/std/sys/pipe.yo +1 -0
- package/std/sys/process.yo +5 -4
- package/std/sys/signal.yo +1 -0
- package/std/sys/socketpair.yo +1 -0
- package/std/sys/sockinfo.yo +1 -0
- package/std/sys/statfs.yo +2 -1
- package/std/sys/statx.yo +1 -0
- package/std/sys/sysinfo.yo +1 -0
- package/std/sys/tcp.yo +15 -14
- package/std/sys/temp.yo +1 -0
- package/std/sys/time.yo +2 -1
- package/std/sys/timer.yo +6 -6
- package/std/sys/tty.yo +2 -1
- package/std/sys/udp.yo +13 -12
- package/std/sys/unix.yo +12 -11
- package/std/testing/bench.yo +4 -3
- package/std/thread.yo +7 -6
- package/std/time/datetime.yo +18 -15
- package/std/time/duration.yo +11 -10
- package/std/time/instant.yo +4 -4
- package/std/time/sleep.yo +1 -0
- package/std/url/index.yo +5 -5
- package/std/worker.yo +4 -3
package/std/thread.yo
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
//! OS thread creation and management with per-thread
|
|
1
|
+
//! OS thread creation and management with per-thread Io event loops.
|
|
2
|
+
pragma(Pragma.AllowUnsafe);
|
|
2
3
|
extern(
|
|
3
4
|
"Yo",
|
|
4
5
|
__yo_thread_get_hardware_threads : (fn() -> usize),
|
|
@@ -8,23 +9,23 @@ extern(
|
|
|
8
9
|
extern(
|
|
9
10
|
"Yo",
|
|
10
11
|
__yo_thread_t : Type,
|
|
11
|
-
__yo_thread_spawn : (fn(cb : Impl(Fn(
|
|
12
|
+
__yo_thread_spawn : (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> __yo_thread_t),
|
|
12
13
|
__yo_thread_join : (fn(t : __yo_thread_t) -> unit)
|
|
13
14
|
);
|
|
14
|
-
/// OS thread handle. Each spawned thread gets its own
|
|
15
|
+
/// OS thread handle. Each spawned thread gets its own Io event loop.
|
|
15
16
|
Thread :: struct(
|
|
16
17
|
handle : __yo_thread_t
|
|
17
18
|
);
|
|
18
19
|
impl(
|
|
19
20
|
Thread,
|
|
20
21
|
/// Spawn a new OS thread running the given closure.
|
|
21
|
-
/// The closure receives its own per-thread
|
|
22
|
-
spawn : (fn(cb : Impl(Fn(
|
|
22
|
+
/// The closure receives its own per-thread Io event loop.
|
|
23
|
+
spawn : (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> Self)({
|
|
23
24
|
raw := __yo_thread_spawn(cb);
|
|
24
25
|
Self(raw)
|
|
25
26
|
}),
|
|
26
27
|
/// Block the current thread until this thread completes.
|
|
27
|
-
join : (fn(self :
|
|
28
|
+
join : (fn(ref(self) : Self) -> unit)(
|
|
28
29
|
__yo_thread_join(self.handle)
|
|
29
30
|
)
|
|
30
31
|
);
|
package/std/time/datetime.yo
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
//! now := DateTime.now_utc();
|
|
9
9
|
//! println(now.to_string()); // "2026-02-26T17:41:24Z"
|
|
10
10
|
//! ```
|
|
11
|
+
pragma(Pragma.AllowUnsafe);
|
|
11
12
|
{ String } :: import("../string");
|
|
12
13
|
{ ToString } :: import("../fmt");
|
|
13
14
|
{ CLOCK_REALTIME, clock_gettime } :: import("../sys/clock");
|
|
@@ -111,7 +112,7 @@ impl(
|
|
|
111
112
|
_from_unix_secs(secs, nanos)
|
|
112
113
|
),
|
|
113
114
|
// Convert back to a Unix timestamp (seconds since epoch).
|
|
114
|
-
to_unix : (fn(self :
|
|
115
|
+
to_unix : (fn(ref(self) : Self) -> i64)({
|
|
115
116
|
// Compute days since epoch using the inverse Gregorian algorithm
|
|
116
117
|
y := i64(self.year);
|
|
117
118
|
m := i64(self.month);
|
|
@@ -136,11 +137,11 @@ impl(
|
|
|
136
137
|
(days * i64(86400)) + time_secs
|
|
137
138
|
}),
|
|
138
139
|
// True if this year is a leap year.
|
|
139
|
-
is_leap_year : (fn(self :
|
|
140
|
+
is_leap_year : (fn(ref(self) : Self) -> bool)(
|
|
140
141
|
_is_leap_year(self.year)
|
|
141
142
|
),
|
|
142
143
|
// Day of week: 0 = Monday, 6 = Sunday (ISO 8601).
|
|
143
|
-
day_of_week : (fn(self :
|
|
144
|
+
day_of_week : (fn(ref(self) : Self) -> u8)({
|
|
144
145
|
// Tomohiko Sakamoto's algorithm
|
|
145
146
|
t := Array(i32, usize(12))(
|
|
146
147
|
i32(0),
|
|
@@ -171,7 +172,7 @@ impl(
|
|
|
171
172
|
)
|
|
172
173
|
}),
|
|
173
174
|
// Day of year (1-based).
|
|
174
|
-
day_of_year : (fn(self :
|
|
175
|
+
day_of_year : (fn(ref(self) : Self) -> u16)({
|
|
175
176
|
m := i32(self.month);
|
|
176
177
|
d := i32(self.day);
|
|
177
178
|
// Sum days in preceding months
|
|
@@ -194,19 +195,21 @@ impl(
|
|
|
194
195
|
impl(
|
|
195
196
|
DateTime,
|
|
196
197
|
ToString(
|
|
197
|
-
to_string : (fn(self :
|
|
198
|
+
to_string : (fn(ref(self) : Self) -> String)({
|
|
198
199
|
buf := Array(u8, usize(32)).fill(u8(0));
|
|
199
200
|
buf_ptr := &(buf(usize(0)));
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
201
|
+
unsafe(
|
|
202
|
+
snprintf(
|
|
203
|
+
*(char)(buf_ptr),
|
|
204
|
+
usize(32),
|
|
205
|
+
"%04d-%02u-%02uT%02u:%02u:%02uZ",
|
|
206
|
+
self.year,
|
|
207
|
+
self.month,
|
|
208
|
+
self.day,
|
|
209
|
+
self.hour,
|
|
210
|
+
self.minute,
|
|
211
|
+
self.second
|
|
212
|
+
)
|
|
210
213
|
);
|
|
211
214
|
String.from_cstr(buf_ptr).unwrap()
|
|
212
215
|
})
|
package/std/time/duration.yo
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
//! println(d.as_secs()); // 0
|
|
10
10
|
//! println(d.as_millis()); // 500
|
|
11
11
|
//! ```
|
|
12
|
+
pragma(Pragma.AllowUnsafe);
|
|
12
13
|
{ String } :: import("../string");
|
|
13
14
|
{ ToString } :: import("../fmt");
|
|
14
15
|
{ snprintf } :: import("../libc/stdio");
|
|
@@ -40,27 +41,27 @@ impl(
|
|
|
40
41
|
Self(secs : (nanos / i64(1000000000)), nanos : (nanos % i64(1000000000)))
|
|
41
42
|
),
|
|
42
43
|
// Total whole seconds in the duration.
|
|
43
|
-
as_secs : (fn(self :
|
|
44
|
+
as_secs : (fn(ref(self) : Self) -> i64)(
|
|
44
45
|
self.secs
|
|
45
46
|
),
|
|
46
47
|
// Total milliseconds (truncated).
|
|
47
|
-
as_millis : (fn(self :
|
|
48
|
+
as_millis : (fn(ref(self) : Self) -> i64)(
|
|
48
49
|
(self.secs * i64(1000)) + (self.nanos / i64(1000000))
|
|
49
50
|
),
|
|
50
51
|
// Total microseconds (truncated).
|
|
51
|
-
as_micros : (fn(self :
|
|
52
|
+
as_micros : (fn(ref(self) : Self) -> i64)(
|
|
52
53
|
(self.secs * i64(1000000)) + (self.nanos / i64(1000))
|
|
53
54
|
),
|
|
54
55
|
// Total nanoseconds.
|
|
55
|
-
as_nanos : (fn(self :
|
|
56
|
+
as_nanos : (fn(ref(self) : Self) -> i64)(
|
|
56
57
|
(self.secs * i64(1000000000)) + self.nanos
|
|
57
58
|
),
|
|
58
59
|
// Total seconds as a floating-point number.
|
|
59
|
-
as_secs_f64 : (fn(self :
|
|
60
|
+
as_secs_f64 : (fn(ref(self) : Self) -> f64)(
|
|
60
61
|
f64(self.secs) + (f64(self.nanos) / f64(1000000000.0))
|
|
61
62
|
),
|
|
62
63
|
// Add two durations together.
|
|
63
|
-
add : (fn(self :
|
|
64
|
+
add : (fn(ref(self) : Self, other : Duration) -> Duration)({
|
|
64
65
|
total_nanos := (self.nanos + other.nanos);
|
|
65
66
|
carry := (total_nanos / i64(1000000000));
|
|
66
67
|
Duration(
|
|
@@ -69,7 +70,7 @@ impl(
|
|
|
69
70
|
)
|
|
70
71
|
}),
|
|
71
72
|
// Subtract another duration (saturates to zero if negative).
|
|
72
|
-
sub : (fn(self :
|
|
73
|
+
sub : (fn(ref(self) : Self, other : Duration) -> Duration)({
|
|
73
74
|
self_ns := self.as_nanos();
|
|
74
75
|
other_ns := other.as_nanos();
|
|
75
76
|
cond(
|
|
@@ -78,17 +79,17 @@ impl(
|
|
|
78
79
|
)
|
|
79
80
|
}),
|
|
80
81
|
// Return true if this duration is zero.
|
|
81
|
-
is_zero : (fn(self :
|
|
82
|
+
is_zero : (fn(ref(self) : Self) -> bool)(
|
|
82
83
|
(self.secs == i64(0)) && (self.nanos == i64(0))
|
|
83
84
|
)
|
|
84
85
|
);
|
|
85
86
|
impl(
|
|
86
87
|
Duration,
|
|
87
88
|
ToString(
|
|
88
|
-
to_string : (fn(self :
|
|
89
|
+
to_string : (fn(ref(self) : Self) -> String)({
|
|
89
90
|
buf := Array(u8, usize(64)).fill(u8(0));
|
|
90
91
|
buf_ptr := &(buf(usize(0)));
|
|
91
|
-
snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos);
|
|
92
|
+
unsafe(snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos));
|
|
92
93
|
String.from_cstr(buf_ptr).unwrap()
|
|
93
94
|
})
|
|
94
95
|
)
|
package/std/time/instant.yo
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
//! elapsed := start.elapsed();
|
|
11
11
|
//! println(elapsed.as_millis());
|
|
12
12
|
//! ```
|
|
13
|
+
pragma(Pragma.AllowUnsafe);
|
|
13
14
|
{ Duration } :: import("./duration");
|
|
14
15
|
{ CLOCK_MONOTONIC, clock_gettime } :: import("../sys/clock");
|
|
15
16
|
/// Snapshot from the monotonic clock. Use `elapsed` to measure durations.
|
|
@@ -29,7 +30,7 @@ impl(
|
|
|
29
30
|
}),
|
|
30
31
|
// Duration between this instant and an earlier one.
|
|
31
32
|
// Returns Duration.zero() if `earlier` is actually later.
|
|
32
|
-
duration_since : (fn(self :
|
|
33
|
+
duration_since : (fn(ref(self) : Self, earlier : Instant) -> Duration)({
|
|
33
34
|
self_ns := ((self.secs * i64(1000000000)) + self.nanos);
|
|
34
35
|
earlier_ns := ((earlier.secs * i64(1000000000)) + earlier.nanos);
|
|
35
36
|
cond(
|
|
@@ -38,10 +39,9 @@ impl(
|
|
|
38
39
|
)
|
|
39
40
|
}),
|
|
40
41
|
// Duration elapsed since this instant was created.
|
|
41
|
-
elapsed : (fn(self :
|
|
42
|
+
elapsed : (fn(ref(self) : Self) -> Duration)({
|
|
42
43
|
current := Instant.now();
|
|
43
|
-
|
|
44
|
-
cur_ptr.duration_since(self.*)
|
|
44
|
+
current.duration_since(self)
|
|
45
45
|
})
|
|
46
46
|
);
|
|
47
47
|
export(Instant);
|
package/std/time/sleep.yo
CHANGED
package/std/url/index.yo
CHANGED
|
@@ -51,7 +51,7 @@ _DOT :: u8(46); // '.'
|
|
|
51
51
|
// ============================================================================
|
|
52
52
|
// Helper: parse port number from bytes
|
|
53
53
|
// ============================================================================
|
|
54
|
-
_parse_port :: (fn(s : str, start : usize, end : usize,
|
|
54
|
+
_parse_port :: (fn(s : str, start : usize, end : usize, exn : Exception) -> u16)({
|
|
55
55
|
cond(
|
|
56
56
|
(start >= end) => {
|
|
57
57
|
exn.throw(dyn(UrlError.InvalidPort));
|
|
@@ -95,7 +95,7 @@ impl(
|
|
|
95
95
|
// Parse a URL string.
|
|
96
96
|
// Supports: scheme://[userinfo@]host[:port]/path[?query][#fragment]
|
|
97
97
|
// Also supports scheme:path (opaque URIs like mailto:user@example.com)
|
|
98
|
-
parse : (fn(s : str,
|
|
98
|
+
parse : (fn(s : str, exn : Exception) -> Url)({
|
|
99
99
|
cond(
|
|
100
100
|
(s.len() == usize(0)) => {
|
|
101
101
|
exn.throw(dyn(UrlError.EmptyInput));
|
|
@@ -234,7 +234,7 @@ impl(
|
|
|
234
234
|
after_bracket := (bracket_end + usize(1));
|
|
235
235
|
cond(
|
|
236
236
|
((after_bracket < auth_end) && (s.bytes(after_bracket) == _COLON)) => {
|
|
237
|
-
port =.Some(_parse_port(s, after_bracket + usize(1), auth_end));
|
|
237
|
+
port =.Some(_parse_port(s, after_bracket + usize(1), auth_end, exn));
|
|
238
238
|
},
|
|
239
239
|
true => ()
|
|
240
240
|
);
|
|
@@ -264,7 +264,7 @@ impl(
|
|
|
264
264
|
hh2 = (hh2 + usize(1));
|
|
265
265
|
});
|
|
266
266
|
host =.Some(String.from_bytes(host_b));
|
|
267
|
-
port =.Some(_parse_port(s, cp_val + usize(1), auth_end));
|
|
267
|
+
port =.Some(_parse_port(s, cp_val + usize(1), auth_end, exn));
|
|
268
268
|
},
|
|
269
269
|
.None => {
|
|
270
270
|
// No port, entire range is host
|
|
@@ -363,7 +363,7 @@ impl(
|
|
|
363
363
|
);
|
|
364
364
|
// Ensure authority-based URLs have a path starting with "/" or empty
|
|
365
365
|
cond(
|
|
366
|
-
(has_authority && ((!(path_str.is_empty())) && (path_str.as_bytes()
|
|
366
|
+
(has_authority && ((!(path_str.is_empty())) && (path_str.as_bytes()(usize(0)) != _SLASH))) => {
|
|
367
367
|
exn.throw(dyn(UrlError.Other(`authority path must start with '/'`)));
|
|
368
368
|
},
|
|
369
369
|
true => ()
|
package/std/worker.yo
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
//! Thread pool with per-core thread affinity and round-robin task distribution.
|
|
2
2
|
//!
|
|
3
3
|
//! Each task is pinned to a worker thread (no work stealing).
|
|
4
|
-
//! Each worker thread has its own GC heap and async
|
|
4
|
+
//! Each worker thread has its own GC heap and async Io event loop.
|
|
5
|
+
pragma(Pragma.AllowUnsafe);
|
|
5
6
|
extern(
|
|
6
7
|
"Yo",
|
|
7
|
-
__yo_worker_spawn : (fn(cb : Impl(Fn(
|
|
8
|
+
__yo_worker_spawn : (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> unit),
|
|
8
9
|
__yo_worker_get_num_threads : (fn() -> usize),
|
|
9
10
|
__yo_worker_set_num_threads : (fn(num : usize) -> unit)
|
|
10
11
|
);
|
|
11
12
|
/// Spawn a task on the thread pool. Returns immediately; the task runs in the background.
|
|
12
13
|
/// Tasks are distributed round-robin to worker threads.
|
|
13
|
-
spawn :: (fn(cb : Impl(Fn(
|
|
14
|
+
spawn :: (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> unit)({
|
|
14
15
|
__yo_worker_spawn(cb);
|
|
15
16
|
});
|
|
16
17
|
/// Get the number of worker threads in the pool.
|