Skip to content

Commit 7b03f0b

Browse files
authored
update to Zig 0.16.0-dev.2510+bcb5218a2 (#35)
1 parent 922e9c2 commit 7b03f0b

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Provides the necessary building blocks to develop Language Server Protocol imple
1010
# Installation
1111

1212
> [!NOTE]
13-
> The default branch requires Zig `0.16.0-dev.1976+8e091047b` or later. Checkout the `0.15.x` branch when using Zig 0.15
13+
> The default branch requires Zig `0.16.0-dev.2510+bcb5218a2` or later. Checkout the `0.15.x` branch when using Zig 0.15
1414
1515
```bash
1616
# Initialize a `zig build` project if you haven't already

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.{
22
.name = .lsp_kit,
33
.version = "0.1.0",
4-
.minimum_zig_version = "0.16.0-dev.1976+8e091047b",
4+
.minimum_zig_version = "0.16.0-dev.2510+bcb5218a2",
55
.dependencies = .{},
66
.paths = .{
77
"build.zig",

examples/hello_client.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn main(init: std.process.Init) !void {
7171
//
7272
// The `lsp.Transport.Stdio` implements the necessary logic to read and write messages over stdio.
7373
var read_buffer: [256]u8 = undefined;
74-
var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, .{ .handle = child_process.stdout.?.handle }, child_process.stdin.?);
74+
var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, child_process.stdout.?, child_process.stdin.?);
7575
const transport: *lsp.Transport = &stdio_transport.transport;
7676

7777
// The order of exchanged messages will look similar to this:

src/lsp.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)