@@ -4,8 +4,9 @@ const tracy = @import("tracy");
44const offsets = @import ("offsets.zig" );
55const Uri = @import ("Uri.zig" );
66
7+ io : std.Io ,
78allocator : std.mem.Allocator ,
8- mutex : std.Thread .Mutex = .{} ,
9+ mutex : std.Io .Mutex = .init ,
910tag_set : std .AutoArrayHashMapUnmanaged (Tag , struct {
1011 version : u32 = 0 ,
1112 error_bundle_src_base_path : ? []const u8 = null ,
@@ -74,8 +75,8 @@ pub fn pushSingleDocumentDiagnostics(
7475 const tracy_zone = tracy .trace (@src ());
7576 defer tracy_zone .end ();
7677
77- collection .mutex .lock ( );
78- defer collection .mutex .unlock ();
78+ collection .mutex .lockUncancelable ( collection . io );
79+ defer collection .mutex .unlock (collection . io );
7980
8081 const gop_tag = try collection .tag_set .getOrPutValue (collection .allocator , tag , .{});
8182
@@ -130,8 +131,8 @@ pub fn pushErrorBundle(
130131 try new_error_bundle .init (collection .allocator );
131132 defer new_error_bundle .deinit ();
132133
133- collection .mutex .lock ( );
134- defer collection .mutex .unlock ();
134+ collection .mutex .lockUncancelable ( collection . io );
135+ defer collection .mutex .unlock (collection . io );
135136
136137 const gop = try collection .tag_set .getOrPutValue (collection .allocator , tag , .{});
137138 const version_order = std .math .order (version , gop .value_ptr .version );
@@ -188,8 +189,8 @@ pub fn clearErrorBundle(collection: *DiagnosticsCollection, tag: Tag) void {
188189 const tracy_zone = tracy .trace (@src ());
189190 defer tracy_zone .end ();
190191
191- collection .mutex .lock ( );
192- defer collection .mutex .unlock ();
192+ collection .mutex .lockUncancelable ( collection . io );
193+ defer collection .mutex .unlock (collection . io );
193194
194195 const item = collection .tag_set .getPtr (tag ) orelse return ;
195196
@@ -214,8 +215,8 @@ pub fn clearSingleDocumentDiagnostics(collection: *DiagnosticsCollection, docume
214215 const tracy_zone = tracy .trace (@src ());
215216 defer tracy_zone .end ();
216217
217- collection .mutex .lock ( );
218- defer collection .mutex .unlock ();
218+ collection .mutex .lockUncancelable ( collection . io );
219+ defer collection .mutex .unlock (collection . io );
219220
220221 for (collection .tag_set .values ()) | * item | {
221222 var kv = item .diagnostics_set .fetchSwapRemove (document_uri ) orelse continue ;
@@ -270,8 +271,8 @@ pub fn publishDiagnostics(collection: *DiagnosticsCollection) (std.mem.Allocator
270271
271272 while (true ) {
272273 const json_message = blk : {
273- collection .mutex .lock ( );
274- defer collection .mutex .unlock ();
274+ collection .mutex .lockUncancelable ( collection . io );
275+ defer collection .mutex .unlock (collection . io );
275276
276277 const entry = collection .outdated_files .pop () orelse break ;
277278 defer entry .key .deinit (collection .allocator );
@@ -486,7 +487,10 @@ test DiagnosticsCollection {
486487
487488 const arena = arena_allocator .allocator ();
488489
489- var collection : DiagnosticsCollection = .{ .allocator = std .testing .allocator };
490+ var collection : DiagnosticsCollection = .{
491+ .io = std .testing .io ,
492+ .allocator = std .testing .allocator ,
493+ };
490494 defer collection .deinit ();
491495
492496 try std .testing .expectEqual (0 , collection .outdated_files .count ());
@@ -558,7 +562,10 @@ test DiagnosticsCollection {
558562}
559563
560564test "DiagnosticsCollection - compile_log_text" {
561- var collection : DiagnosticsCollection = .{ .allocator = std .testing .allocator };
565+ var collection : DiagnosticsCollection = .{
566+ .io = std .testing .io ,
567+ .allocator = std .testing .allocator ,
568+ };
562569 defer collection .deinit ();
563570
564571 var eb = try createTestingErrorBundle (&.{.{ .message = "found compile log statement" }}, "@as(comptime_int, 7)\n @as(comptime_int, 13)" );
0 commit comments