@@ -1244,7 +1244,7 @@ pub const ThreadSafeTransportConfig = struct {
12441244 thread_safe_read : bool ,
12451245 /// Makes `writeJsonMessage` thread-safe.
12461246 thread_safe_write : bool ,
1247- MutexType : type = std .Thread .Mutex ,
1247+ MutexType : type = std .Io .Mutex ,
12481248};
12491249
12501250/// Wraps a non-thread-safe transport and makes it thread-safe.
@@ -1273,34 +1273,34 @@ pub fn ThreadSafeTransport(config: ThreadSafeTransportConfig) type {
12731273 pub fn readJsonMessage (transport : * Transport , io : std.Io , allocator : std.mem.Allocator ) Transport.ReadError ! []u8 {
12741274 const self : * Self = @fieldParentPtr ("transport" , transport );
12751275
1276- self .in_mutex .lock ();
1277- defer self .in_mutex .unlock ();
1276+ try self .in_mutex .lock (io );
1277+ defer self .in_mutex .unlock (io );
12781278
12791279 return try self .child_transport .readJsonMessage (io , allocator );
12801280 }
12811281
12821282 pub fn writeJsonMessage (transport : * Transport , io : std.Io , json_message : []const u8 ) Transport.WriteError ! void {
12831283 const self : * Self = @fieldParentPtr ("transport" , transport );
12841284
1285- self .out_mutex .lock ();
1286- defer self .out_mutex .unlock ();
1285+ try self .out_mutex .lock (io );
1286+ defer self .out_mutex .unlock (io );
12871287
12881288 return try self .child_transport .writeJsonMessage (io , json_message );
12891289 }
12901290
12911291 const in_mutex_init = if (config .thread_safe_read )
1292- config.MutexType {}
1292+ config .MutexType . init
12931293 else
12941294 DummyMutex {};
12951295
12961296 const out_mutex_init = if (config .thread_safe_write )
1297- config.MutexType {}
1297+ config .MutexType . init
12981298 else
12991299 DummyMutex {};
13001300
13011301 const DummyMutex = struct {
1302- fn lock (_ : * DummyMutex ) void {}
1303- fn unlock (_ : * DummyMutex ) void {}
1302+ pub fn lock (_ : * DummyMutex , _ : std.Io ) ! void {}
1303+ pub fn unlock (_ : * DummyMutex , _ : std.Io ) void {}
13041304 };
13051305 };
13061306}
0 commit comments