From 16a370867db5519a38bd8bdc2f33d11fc9b12e0d Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 21 Dec 2024 20:36:50 +0100 Subject: [PATCH 01/11] build: update dependencies for zig-0.14.0-dev.2546 compatibility --- build.zig.zon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index bdc73a8..95ed4e7 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,12 +4,12 @@ .dependencies = .{ .asio = .{ - .url = "https://github.com/neurocyte/asio/archive/b9c9c23ef2e6f11b6123535ec33e5a23ed0c59da.tar.gz", - .hash = "1220c85e0d9438ec518849c84e3ea66633a0e191e49c4ae4bbb3bc46626cd8dfad75", + .url = "https://github.com/neurocyte/asio/archive/8cc76c9ed4054f45bfc06476d795477096aab7a5.tar.gz", + .hash = "12206a4050ebb2e2bf84ed477ea5fe0d0325f9292eef2cb8bd47ccda75a9b3d93516", }, .tracy = .{ - .url = "https://github.com/neurocyte/zig-tracy/archive/58999b786089e5319dd0707f6afbfca04c6340e7.tar.gz", - .hash = "1220a2c8f8db1b5265458ac967ea1f7cc0a8ddcd1d774df3b73d86c4f529aadbfb94", + .url = "https://github.com/neurocyte/zig-tracy/archive/80b914d2391209de9ed5a1fd6f440642df55cbd4.tar.gz", + .hash = "1220351c8410936854e3baa10aa7bbe775196b3974a3d670808bebbab00631439285", }, }, .paths = .{ From 42b3f72c44589c4903d5a9d0683b650e04bdf3dc Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 21 Dec 2024 20:37:25 +0100 Subject: [PATCH 02/11] build: update to zig-0.14.0-dev.2546 --- build.zig | 4 ++-- build.zig.version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 4c1fb66..52f1ec7 100644 --- a/build.zig +++ b/build.zig @@ -40,8 +40,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); if (tracy_enabled) { - lib.defineCMacro("TRACY_ENABLE", null); - lib.defineCMacro("TRACY_CALLSTACK", null); + lib.root_module.addCMacro("TRACY_ENABLE", "1"); + lib.root_module.addCMacro("TRACY_CALLSTACK", "1"); } lib.addIncludePath(b.path("src")); lib.addIncludePath(b.path("include")); diff --git a/build.zig.version b/build.zig.version index 54d1a4f..1ce7f78 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.13.0 +0.14.0-dev.2546+0ff0bdb4a From c6432f7490455aabafb1f02ac5bf99e4ef1e6282 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 21 Dec 2024 20:51:51 +0100 Subject: [PATCH 03/11] build: update to zig-0.14.0-dev.2546 --- src/cbor.zig | 58 ++++++++++++++++++++++----------------------- src/thespian.zig | 10 ++++---- test/tests_cbor.zig | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/cbor.zig b/src/cbor.zig index f202518..cf97696 100644 --- a/src/cbor.zig +++ b/src/cbor.zig @@ -209,12 +209,12 @@ fn writeErrorset(writer: anytype, err: anyerror) @TypeOf(writer).Error!void { pub fn writeValue(writer: anytype, value: anytype) @TypeOf(writer).Error!void { const T = @TypeOf(value); switch (@typeInfo(T)) { - .Int, .ComptimeInt => return if (T == u64) writeU64(writer, value) else writeI64(writer, @intCast(value)), - .Bool => return writeBool(writer, value), - .Optional => return if (value) |v| writeValue(writer, v) else writeNull(writer), - .ErrorUnion => return if (value) |v| writeValue(writer, v) else |err| writeValue(writer, err), - .ErrorSet => return writeErrorset(writer, value), - .Union => |info| { + .int, .comptime_int => return if (T == u64) writeU64(writer, value) else writeI64(writer, @intCast(value)), + .bool => return writeBool(writer, value), + .optional => return if (value) |v| writeValue(writer, v) else writeNull(writer), + .error_union => return if (value) |v| writeValue(writer, v) else |err| writeValue(writer, err), + .error_set => return writeErrorset(writer, value), + .@"union" => |info| { if (info.tag_type) |TagType| { comptime var v = void; inline for (info.fields) |u_field| { @@ -230,7 +230,7 @@ pub fn writeValue(writer: anytype, value: anytype) @TypeOf(writer).Error!void { try writeArray(writer, .{@typeName(T)}); } }, - .Struct => |info| { + .@"struct" => |info| { if (info.is_tuple) { if (info.fields.len == 0) return writeNull(writer); try writeArrayHeader(writer, info.fields.len); @@ -245,7 +245,7 @@ pub fn writeValue(writer: anytype, value: anytype) @TypeOf(writer).Error!void { } } }, - .Pointer => |ptr_info| switch (ptr_info.size) { + .pointer => |ptr_info| switch (ptr_info.size) { .One => return writeValue(writer, value.*), .Many, .C => @compileError("cannot write type '" ++ @typeName(T) ++ "' to cbor stream"), .Slice => { @@ -256,22 +256,22 @@ pub fn writeValue(writer: anytype, value: anytype) @TypeOf(writer).Error!void { try writeValue(writer, elem); }, }, - .Array => |info| { + .array => |info| { if (info.child == u8) return writeString(writer, &value); if (value.len == 0) return writeNull(writer); try writeArrayHeader(writer, value.len); for (value) |elem| try writeValue(writer, elem); }, - .Vector => |info| { + .vector => |info| { try writeArrayHeader(writer, info.len); var i: usize = 0; while (i < info.len) : (i += 1) { try writeValue(writer, value[i]); } }, - .Null => try writeNull(writer), - .Float => |info| switch (info.bits) { + .null => try writeNull(writer), + .float => |info| switch (info.bits) { 16 => try writeF16(writer, value), 32 => try writeF32(writer, value), 64 => try writeF64(writer, value), @@ -380,7 +380,7 @@ fn decodeJsonObject(iter_: *[]const u8, minor: u5, obj: *json.ObjectMap) Error!b var iter = iter_.*; var n = try decodePInt(&iter, minor); while (n > 0) { - var key: []u8 = undefined; + var key: []const u8 = undefined; var value: json.Value = .null; if (!try matchString(&iter, &key)) @@ -642,21 +642,21 @@ pub fn matchValue(iter: *[]const u8, value: anytype) Error!bool { if (comptime isExtractor(T)) return value.extract(iter); return switch (comptime @typeInfo(T)) { - .Int => return matchIntValue(T, iter, value), - .ComptimeInt => return matchIntValue(i64, iter, value), - .Bool => matchBoolValue(iter, value), - .Pointer => |info| switch (info.size) { + .int => return matchIntValue(T, iter, value), + .comptime_int => return matchIntValue(i64, iter, value), + .bool => matchBoolValue(iter, value), + .pointer => |info| switch (info.size) { .One => matchValue(iter, value.*), .Many, .C => matchError(T), .Slice => if (info.child == u8) matchStringValue(iter, value) else matchArray(iter, value, info), }, - .Struct => |info| if (info.is_tuple) + .@"struct" => |info| if (info.is_tuple) matchArray(iter, value, info) else matchError(T), - .Array => |info| if (info.child == u8) matchStringValue(iter, &value) else matchArray(iter, value, info), - .Float => return matchFloatValue(T, iter, value), - .ComptimeFloat => matchFloatValue(f64, iter, value), + .array => |info| if (info.child == u8) matchStringValue(iter, &value) else matchArray(iter, value, info), + .float => return matchFloatValue(T, iter, value), + .comptime_float => matchFloatValue(f64, iter, value), else => @compileError("cannot match value type '" ++ @typeName(T) ++ "' to cbor stream"), }; } @@ -784,7 +784,7 @@ fn hasExtractorTag(info: anytype) bool { fn isExtractor(comptime T: type) bool { return comptime switch (@typeInfo(T)) { - .Struct => |info| hasExtractorTag(info), + .@"struct" => |info| hasExtractorTag(info), else => false, }; } @@ -837,15 +837,15 @@ fn Extractor(comptime T: type) type { pub fn extract(self: Self, iter: *[]const u8) Error!bool { switch (comptime @typeInfo(T)) { - .Int, .ComptimeInt => return matchInt(T, iter, self.dest), - .Bool => return matchBool(iter, self.dest), - .Pointer => |ptr_info| switch (ptr_info.size) { + .int, .comptime_int => return matchInt(T, iter, self.dest), + .bool => return matchBool(iter, self.dest), + .pointer => |ptr_info| switch (ptr_info.size) { .Slice => { if (ptr_info.child == u8) return matchString(iter, self.dest) else extractError(T); }, else => extractError(T), }, - .Optional => |opt_info| { + .optional => |opt_info| { var nested: opt_info.child = undefined; const extractor = Extractor(opt_info.child).init(&nested); if (try extractor.extract(iter)) { @@ -854,7 +854,7 @@ fn Extractor(comptime T: type) type { } return false; }, - .Float => return matchFloat(T, iter, self.dest), + .float => return matchFloat(T, iter, self.dest), else => extractError(T), } } @@ -863,8 +863,8 @@ fn Extractor(comptime T: type) type { fn ExtractorType(comptime T: type) type { const T_type_info = @typeInfo(T); - if (T_type_info != .Pointer) @compileError("extract requires a pointer argument"); - return Extractor(T_type_info.Pointer.child); + if (T_type_info != .pointer) @compileError("extract requires a pointer argument"); + return Extractor(T_type_info.pointer.child); } pub fn extract(dest: anytype) ExtractorType(@TypeOf(dest)) { diff --git a/src/thespian.zig b/src/thespian.zig index 19bdcf0..b9a3731 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -138,7 +138,7 @@ pub const message = struct { pub fn fmt(value: anytype) Self { message_buffer.clearRetainingCapacity(); const f = comptime switch (@typeInfo(@TypeOf(value))) { - .Struct => |info| if (info.is_tuple) + .@"struct" => |info| if (info.is_tuple) fmt_internal else @compileError("thespian.message template should be a tuple: " ++ @typeName(@TypeOf(value))), @@ -158,7 +158,7 @@ pub const message = struct { pub fn fmtbuf(buf: []u8, value: anytype) !Self { const f = comptime switch (@typeInfo(@TypeOf(value))) { - .Struct => |info| if (info.is_tuple) + .@"struct" => |info| if (info.is_tuple) fmtbuf_internal else @compileError("thespian.message template should be a tuple: " ++ @typeName(@TypeOf(value))), @@ -217,14 +217,14 @@ pub fn exit_message(e: anytype, stack_trace: ?*std.builtin.StackTrace) message { defer debug_info_arena_allocator.deinit(); const a = debug_info_arena_allocator.allocator(); var out = std.ArrayList(u8).init(a); - store_stack_trace(a, stack_trace_.*, out.writer()); + store_stack_trace(stack_trace_.*, out.writer()); return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.items }) catch unreachable; } else { return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable; } } -fn store_stack_trace(a: std.mem.Allocator, stack_trace: std.builtin.StackTrace, writer: anytype) void { +fn store_stack_trace(stack_trace: std.builtin.StackTrace, writer: anytype) void { nosuspend { if (builtin.strip_debug_info) { writer.print("Unable to store stack trace: debug info stripped\n", .{}) catch return; @@ -234,7 +234,7 @@ fn store_stack_trace(a: std.mem.Allocator, stack_trace: std.builtin.StackTrace, writer.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; return; }; - std.debug.writeStackTrace(stack_trace, writer, a, debug_info, .no_color) catch |err| { + std.debug.writeStackTrace(stack_trace, writer, debug_info, .no_color) catch |err| { writer.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; return; }; diff --git a/test/tests_cbor.zig b/test/tests_cbor.zig index f3d52af..1d27410 100644 --- a/test/tests_cbor.zig +++ b/test/tests_cbor.zig @@ -151,7 +151,7 @@ test "cbor.matchValue(i64) multi" { var buf: [128]u8 = undefined; const iter = fmt(&buf, 7); const iter2 = fmt(buf[iter.len..], 8); - var iter3 = buf[0 .. iter.len + iter2.len]; + var iter3: []const u8 = buf[0 .. iter.len + iter2.len]; try expect(try matchValue(&iter3, 7)); try expect(try matchValue(&iter3, 8)); } From fdf7a0c3bb9738b68895cbde63dbae00b74f5a73 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 24 Jan 2025 13:00:36 +0100 Subject: [PATCH 04/11] fix: non-message traces --- src/thespian.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thespian.zig b/src/thespian.zig index 28f6a70..116fae5 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -427,7 +427,8 @@ pub fn trace(chan: trace_channel, value: anytype) void { env.get().trace(value.to(message.c_buffer_type)); } else { var trace_buffer: [512]u8 = undefined; - const m = message.fmtbuf(&trace_buffer, value); + const m = message.fmtbuf(&trace_buffer, value) catch |e| + std.debug.panic("TRACE ERROR: {}", .{e}); env.get().trace(m.to(message.c_buffer_type)); } } From 448d130c7c772cd09a0de7a197a7866954716fe1 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 26 Jan 2025 16:32:13 +0100 Subject: [PATCH 05/11] feat: add debug trace channel --- src/thespian.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thespian.zig b/src/thespian.zig index 116fae5..29e77a5 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -336,6 +336,7 @@ pub const channel = struct { pub const event: c.thespian_trace_channel = 2048; pub const widget: c.thespian_trace_channel = 4096; pub const input: c.thespian_trace_channel = 8192; + pub const debug: c.thespian_trace_channel = 16384; pub const all = c.thespian_trace_channel_all; }; From db3ad5f45e707a04eaa51aa657995abe43ce967a Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 29 Jan 2025 15:32:34 +0100 Subject: [PATCH 06/11] feat: support matching and extracting enums --- src/cbor.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cbor.zig b/src/cbor.zig index c922a1d..f20b1f6 100644 --- a/src/cbor.zig +++ b/src/cbor.zig @@ -522,6 +522,21 @@ fn matchFloatValue(comptime T: type, iter: *[]const u8, val: T) Error!bool { return if (try matchFloat(T, iter, &v)) v == val else false; } +pub fn matchEnum(comptime T: type, iter_: *[]const u8, val: *T) Error!bool { + var iter = iter_.*; + var str: []const u8 = undefined; + if (try matchString(&iter, &str)) if (std.meta.stringToEnum(T, str)) |val_| { + val.* = val_; + iter_.* = iter; + return true; + }; + return false; +} + +fn matchEnumValue(comptime T: type, iter: *[]const u8, val: T) Error!bool { + return matchStringValue(iter, @tagName(val)); +} + fn skipString(iter: *[]const u8, minor: u5) Error!void { const len: usize = @intCast(try decodePInt(iter, minor)); if (iter.len < len) @@ -657,6 +672,7 @@ pub fn matchValue(iter: *[]const u8, value: anytype) Error!bool { .Array => |info| if (info.child == u8) matchStringValue(iter, &value) else matchArray(iter, value, info), .Float => return matchFloatValue(T, iter, value), .ComptimeFloat => matchFloatValue(f64, iter, value), + .Enum => matchEnumValue(T, iter, value), else => @compileError("cannot match value type '" ++ @typeName(T) ++ "' to cbor stream"), }; } @@ -855,6 +871,7 @@ fn Extractor(comptime T: type) type { return false; }, .Float => return matchFloat(T, iter, self.dest), + .Enum => return matchEnum(T, iter, self.dest), else => extractError(T), } } From 72aa6150c5940a8b3e6bdca1dc06cb6ac95bc1ed Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 21:05:33 +0100 Subject: [PATCH 07/11] build: update to 0.14.0-dev.3039 --- build.zig.version | 2 +- src/cbor.zig | 14 +++++++------- src/thespian.zig | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.zig.version b/build.zig.version index 1ce7f78..871de6e 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.14.0-dev.2546+0ff0bdb4a +0.14.0-dev.3039+e61acd8eb diff --git a/src/cbor.zig b/src/cbor.zig index fe3f633..2d791c8 100644 --- a/src/cbor.zig +++ b/src/cbor.zig @@ -246,9 +246,9 @@ pub fn writeValue(writer: anytype, value: anytype) @TypeOf(writer).Error!void { } }, .pointer => |ptr_info| switch (ptr_info.size) { - .One => return writeValue(writer, value.*), - .Many, .C => @compileError("cannot write type '" ++ @typeName(T) ++ "' to cbor stream"), - .Slice => { + .one => return writeValue(writer, value.*), + .many, .c => @compileError("cannot write type '" ++ @typeName(T) ++ "' to cbor stream"), + .slice => { if (ptr_info.child == u8) return writeString(writer, value); if (value.len == 0) return writeNull(writer); try writeArrayHeader(writer, value.len); @@ -661,9 +661,9 @@ pub fn matchValue(iter: *[]const u8, value: anytype) Error!bool { .comptime_int => return matchIntValue(i64, iter, value), .bool => matchBoolValue(iter, value), .pointer => |info| switch (info.size) { - .One => matchValue(iter, value.*), - .Many, .C => matchError(T), - .Slice => if (info.child == u8) matchStringValue(iter, value) else matchArray(iter, value, info), + .one => matchValue(iter, value.*), + .many, .c => matchError(T), + .slice => if (info.child == u8) matchStringValue(iter, value) else matchArray(iter, value, info), }, .@"struct" => |info| if (info.is_tuple) matchArray(iter, value, info) @@ -856,7 +856,7 @@ fn Extractor(comptime T: type) type { .int, .comptime_int => return matchInt(T, iter, self.dest), .bool => return matchBool(iter, self.dest), .pointer => |ptr_info| switch (ptr_info.size) { - .Slice => { + .slice => { if (ptr_info.child == u8) return matchString(iter, self.dest) else extractError(T); }, else => extractError(T), diff --git a/src/thespian.zig b/src/thespian.zig index 8db8d9c..7a476b5 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -260,7 +260,7 @@ pub fn exit_fmt(comptime fmt: anytype, args: anytype) error{Exit} { } pub fn exit_error(e: anyerror, stack_trace: ?*std.builtin.StackTrace) error{Exit} { - if (stack_trace_on_errors and e == error.OutOfMemory) std.debug.panicExtra(stack_trace, null, "{any}", .{e}); + if (stack_trace_on_errors and e == error.OutOfMemory) std.debug.panic("{any}", .{e}); return switch (e) { error.Exit => error.Exit, else => set_error_msg(exit_message(e, stack_trace)), From 063c441c30aafd212b4d8e97555590594855a082 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 22:52:28 +0100 Subject: [PATCH 08/11] fix: build with 0.14.0-dev.3039 --- src/subprocess.zig | 4 ++-- src/thespian.zig | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/subprocess.zig b/src/subprocess.zig index d7bddf0..7a2ee03 100644 --- a/src/subprocess.zig +++ b/src/subprocess.zig @@ -145,9 +145,9 @@ const Proc = struct { fn receive(self: *Proc, _: tp.pid_ref, m: tp.message) tp.result { errdefer self.deinit(); - var bytes: []u8 = ""; + var bytes: []const u8 = ""; var err: i64 = 0; - var err_msg: []u8 = ""; + var err_msg: []const u8 = ""; if (try m.match(.{ "fd", "stdout", "read_ready" })) { try self.dispatch_stdout(); if (self.fd_stdout) |fd_stdout| fd_stdout.wait_read() catch |e| return self.handle_error(e); diff --git a/src/thespian.zig b/src/thespian.zig index 7a476b5..136937d 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -499,14 +499,14 @@ fn log_last_error(err: anytype) @TypeOf(err) { fn exitHandlerRun(comptime T: type) c.thespian_exit_handler { if (T == @TypeOf(null)) return null; return switch (@typeInfo(T)) { - .Optional => |info| switch (@typeInfo(info.child)) { - .Pointer => |ptr_info| switch (ptr_info.size) { - .One => ptr_info.child.run, + .optional => |info| switch (@typeInfo(info.child)) { + .pointer => |ptr_info| switch (ptr_info.size) { + .one => ptr_info.child.run, else => @compileError("expected single item pointer, found: '" ++ @typeName(T) ++ "'"), }, }, - .Pointer => |ptr_info| switch (ptr_info.size) { - .One => ptr_info.child.run, + .pointer => |ptr_info| switch (ptr_info.size) { + .one => ptr_info.child.run, else => @compileError("expected single item pointer, found: '" ++ @typeName(T) ++ "'"), }, else => @compileError("expected optional pointer or pointer type, found: '" ++ @typeName(T) ++ "'"), @@ -515,8 +515,8 @@ fn exitHandlerRun(comptime T: type) c.thespian_exit_handler { pub fn receive(r: anytype) void { const T = switch (@typeInfo(@TypeOf(r))) { - .Pointer => |ptr_info| switch (ptr_info.size) { - .One => ptr_info.child, + .pointer => |ptr_info| switch (ptr_info.size) { + .one => ptr_info.child, else => @compileError("invalid receiver type"), }, else => @compileError("invalid receiver type"), From eb9b8a3dcfbd15e95195951fab0505c337927f39 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 23:29:28 +0100 Subject: [PATCH 09/11] fix: windows build with 0.14.0-dev.3039 --- src/subprocess_windows.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/subprocess_windows.zig b/src/subprocess_windows.zig index e9eaea1..3770ca8 100644 --- a/src/subprocess_windows.zig +++ b/src/subprocess_windows.zig @@ -138,10 +138,10 @@ const Proc = struct { fn receive(self: *Proc, _: tp.pid_ref, m: tp.message) tp.result { errdefer self.deinit(); - var bytes: []u8 = ""; - var stream_name: []u8 = ""; + var bytes: []const u8 = ""; + var stream_name: []const u8 = ""; var err: i64 = 0; - var err_msg: []u8 = ""; + var err_msg: []const u8 = ""; if (try m.match(.{ "stream", "stdout", "read_complete", tp.extract(&bytes) })) { try self.dispatch_stdout(bytes); if (self.stream_stdout) |stream| stream.start_read() catch |e| return self.handle_error(e); @@ -692,7 +692,7 @@ const Child = struct { } var io_status: windows.IO_STATUS_BLOCK = undefined; - const num_supported_pathext = @typeInfo(CreateProcessSupportedExtension).Enum.fields.len; + const num_supported_pathext = @typeInfo(CreateProcessSupportedExtension).@"enum".fields.len; var pathext_seen = [_]bool{false} ** num_supported_pathext; var any_pathext_seen = false; var unappended_exists = false; From 9ca04ddfc715e0f7d29d3f6b39269ad9bf174230 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 11 Feb 2025 18:32:26 +0100 Subject: [PATCH 10/11] feat: add a minimum number of threads to spawn with env MIN_THREAD override --- src/executor_asio.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/executor_asio.cpp b/src/executor_asio.cpp index 69f905d..4cdbc7c 100644 --- a/src/executor_asio.cpp +++ b/src/executor_asio.cpp @@ -58,12 +58,16 @@ using asio::windows::stream_handle; namespace thespian::executor { +const char *MIN_THREAD_STR = getenv("MIN_THREAD"); // NOLINT +const auto MIN_THREAD = + static_cast(atoi(MIN_THREAD_STR ? MIN_THREAD_STR : "4")); // NOLINT + const char *MAX_THREAD_STR = getenv("MAX_THREAD"); // NOLINT const auto MAX_THREAD = static_cast(atoi(MAX_THREAD_STR ? MAX_THREAD_STR : "64")); // NOLINT #if !defined(_WIN32) -const auto threads = min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREAD); +const auto threads = max(min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREAD), MIN_THREAD); #else namespace { static auto get_num_processors() -> long { @@ -72,7 +76,7 @@ static auto get_num_processors() -> long { return si.dwNumberOfProcessors; } } // namespace -const auto threads = min(get_num_processors(), MAX_THREAD); +const auto threads = max(min(get_num_processors(), MAX_THREAD), MIN_THREAD); #endif struct context_impl { From 78c9c1292c683478d8ac98d8318bc098442cc0b9 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 5 Mar 2025 10:56:32 +0100 Subject: [PATCH 11/11] build: update to zig-0.14 --- build.zig.version | 2 +- build.zig.zon | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build.zig.version b/build.zig.version index 871de6e..a803cc2 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.14.0-dev.3039+e61acd8eb +0.14.0 diff --git a/build.zig.zon b/build.zig.zon index 93daaf3..77e30ee 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,15 +1,16 @@ .{ - .name = "thespian", + .name = .thespian, .version = "0.0.1", + .fingerprint = 0xe9ff00fd8e4e01a3, .dependencies = .{ .asio = .{ - .url = "https://github.com/neurocyte/asio/archive/8cc76c9ed4054f45bfc06476d795477096aab7a5.tar.gz", - .hash = "12206a4050ebb2e2bf84ed477ea5fe0d0325f9292eef2cb8bd47ccda75a9b3d93516", + .url = "https://github.com/neurocyte/asio/archive/24d28864ec5aae6146d88a172288e3bf3f099734.tar.gz", + .hash = "asio-1.30.2-tLhDdyKA4QBqQFDrsuK_hO1HfqX-DQMl-Sku7yy4vUfM", }, .tracy = .{ - .url = "https://github.com/neurocyte/zig-tracy/archive/e04e31c64498149a324491b8534758e6af43a5c2.tar.gz", - .hash = "1220d0fb2bff7b453dbb39d1db3eb472b6680e2564f2b23b0e947671be47bbdd188f", + .url = "https://github.com/neurocyte/zig-tracy/archive/f2fe3021501c19816006ab65e3389b1c5f0c3c3a.tar.gz", + .hash = "zig_tracy-0.0.3-5-cp3Kp2AABlufxcWskNe6YfKeqCRpDu7b57JvE-Yj1w", }, }, .paths = .{