fixups from the merge
This commit is contained in:
parent
65140b2fba
commit
7f6e97cb26
@ -694,8 +694,8 @@ async fn asyncFmtMain(
|
|||||||
flags: *const Args,
|
flags: *const Args,
|
||||||
color: errmsg.Color,
|
color: errmsg.Color,
|
||||||
) FmtError!void {
|
) FmtError!void {
|
||||||
suspend |p| {
|
suspend {
|
||||||
resume p;
|
resume @handle();
|
||||||
}
|
}
|
||||||
// Things we need to make event-based:
|
// Things we need to make event-based:
|
||||||
// * opening the file in the first place - the open()
|
// * opening the file in the first place - the open()
|
||||||
|
@ -78,14 +78,9 @@ pub const Request = struct {
|
|||||||
|
|
||||||
/// data - just the inner references - must live until pwritev promise completes.
|
/// data - just the inner references - must live until pwritev promise completes.
|
||||||
pub async fn pwritev(loop: *event.Loop, fd: os.FileHandle, offset: usize, data: []const []const u8) !void {
|
pub async fn pwritev(loop: *event.Loop, fd: os.FileHandle, offset: usize, data: []const []const u8) !void {
|
||||||
//const data_dupe = try mem.dupe(loop.allocator, []const u8, data);
|
|
||||||
//defer loop.allocator.free(data_dupe);
|
|
||||||
|
|
||||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const iovecs = try loop.allocator.alloc(os.linux.iovec_const, data.len);
|
const iovecs = try loop.allocator.alloc(os.linux.iovec_const, data.len);
|
||||||
@ -114,13 +109,13 @@ pub async fn pwritev(loop: *event.Loop, fd: os.FileHandle, offset: usize, data:
|
|||||||
.TickNode = event.Loop.NextTickNode{
|
.TickNode = event.Loop.NextTickNode{
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
.data = my_handle,
|
.data = @handle(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
suspend |_| {
|
suspend {
|
||||||
loop.linuxFsRequest(&req_node);
|
loop.linuxFsRequest(&req_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,10 +128,8 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, offset: usize, data: [
|
|||||||
//defer loop.allocator.free(data_dupe);
|
//defer loop.allocator.free(data_dupe);
|
||||||
|
|
||||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const iovecs = try loop.allocator.alloc(os.linux.iovec, data.len);
|
const iovecs = try loop.allocator.alloc(os.linux.iovec, data.len);
|
||||||
@ -165,13 +158,13 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, offset: usize, data: [
|
|||||||
.TickNode = event.Loop.NextTickNode{
|
.TickNode = event.Loop.NextTickNode{
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
.data = my_handle,
|
.data = @handle(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
suspend |_| {
|
suspend {
|
||||||
loop.linuxFsRequest(&req_node);
|
loop.linuxFsRequest(&req_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,10 +173,8 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, offset: usize, data: [
|
|||||||
|
|
||||||
pub async fn openRead(loop: *event.Loop, path: []const u8) os.File.OpenError!os.FileHandle {
|
pub async fn openRead(loop: *event.Loop, path: []const u8) os.File.OpenError!os.FileHandle {
|
||||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
||||||
@ -203,13 +194,13 @@ pub async fn openRead(loop: *event.Loop, path: []const u8) os.File.OpenError!os.
|
|||||||
.TickNode = event.Loop.NextTickNode{
|
.TickNode = event.Loop.NextTickNode{
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
.data = my_handle,
|
.data = @handle(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
suspend |_| {
|
suspend {
|
||||||
loop.linuxFsRequest(&req_node);
|
loop.linuxFsRequest(&req_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,10 +214,8 @@ pub async fn openReadWrite(
|
|||||||
mode: os.File.Mode,
|
mode: os.File.Mode,
|
||||||
) os.File.OpenError!os.FileHandle {
|
) os.File.OpenError!os.FileHandle {
|
||||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
||||||
@ -247,13 +236,13 @@ pub async fn openReadWrite(
|
|||||||
.TickNode = event.Loop.NextTickNode{
|
.TickNode = event.Loop.NextTickNode{
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
.data = my_handle,
|
.data = @handle(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
suspend |_| {
|
suspend {
|
||||||
loop.linuxFsRequest(&req_node);
|
loop.linuxFsRequest(&req_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,10 +300,8 @@ pub async fn writeFile(loop: *event.Loop, path: []const u8, contents: []const u8
|
|||||||
/// contents must remain alive until writeFile completes.
|
/// contents must remain alive until writeFile completes.
|
||||||
pub async fn writeFileMode(loop: *event.Loop, path: []const u8, contents: []const u8, mode: os.File.Mode) !void {
|
pub async fn writeFileMode(loop: *event.Loop, path: []const u8, contents: []const u8, mode: os.File.Mode) !void {
|
||||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
||||||
@ -336,13 +323,13 @@ pub async fn writeFileMode(loop: *event.Loop, path: []const u8, contents: []cons
|
|||||||
.TickNode = event.Loop.NextTickNode{
|
.TickNode = event.Loop.NextTickNode{
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
.data = my_handle,
|
.data = @handle(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
suspend |_| {
|
suspend {
|
||||||
loop.linuxFsRequest(&req_node);
|
loop.linuxFsRequest(&req_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,14 +407,12 @@ pub fn watchFile(loop: *event.Loop, file_path: []const u8) !*Watch {
|
|||||||
|
|
||||||
async fn watchEventPutter(inotify_fd: i32, wd: i32, channel: *event.Channel(Watch.Event), out_watch: **Watch) void {
|
async fn watchEventPutter(inotify_fd: i32, wd: i32, channel: *event.Channel(Watch.Event), out_watch: **Watch) void {
|
||||||
// TODO https://github.com/ziglang/zig/issues/1194
|
// TODO https://github.com/ziglang/zig/issues/1194
|
||||||
var my_handle: promise = undefined;
|
suspend {
|
||||||
suspend |p| {
|
resume @handle();
|
||||||
my_handle = p;
|
|
||||||
resume p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var watch = Watch{
|
var watch = Watch{
|
||||||
.putter = my_handle,
|
.putter = @handle(),
|
||||||
.channel = channel,
|
.channel = channel,
|
||||||
};
|
};
|
||||||
out_watch.* = &watch;
|
out_watch.* = &watch;
|
||||||
|
@ -98,7 +98,7 @@ pub const Lock = struct {
|
|||||||
var my_tick_node = Loop.NextTickNode.init(@handle());
|
var my_tick_node = Loop.NextTickNode.init(@handle());
|
||||||
|
|
||||||
errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire
|
errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire
|
||||||
suspend |_| {
|
suspend {
|
||||||
self.queue.put(&my_tick_node);
|
self.queue.put(&my_tick_node);
|
||||||
|
|
||||||
// At this point, we are in the queue, so we might have already been resumed and this coroutine
|
// At this point, we are in the queue, so we might have already been resumed and this coroutine
|
||||||
|
@ -97,10 +97,10 @@ pub const RwLock = struct {
|
|||||||
pub async fn acquireRead(self: *RwLock) HeldRead {
|
pub async fn acquireRead(self: *RwLock) HeldRead {
|
||||||
_ = @atomicRmw(usize, &self.reader_lock_count, AtomicRmwOp.Add, 1, AtomicOrder.SeqCst);
|
_ = @atomicRmw(usize, &self.reader_lock_count, AtomicRmwOp.Add, 1, AtomicOrder.SeqCst);
|
||||||
|
|
||||||
suspend |handle| {
|
suspend {
|
||||||
// TODO explicitly put this memory in the coroutine frame #1194
|
// TODO explicitly put this memory in the coroutine frame #1194
|
||||||
var my_tick_node = Loop.NextTickNode{
|
var my_tick_node = Loop.NextTickNode{
|
||||||
.data = handle,
|
.data = @handle(),
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
};
|
};
|
||||||
@ -130,10 +130,10 @@ pub const RwLock = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn acquireWrite(self: *RwLock) HeldWrite {
|
pub async fn acquireWrite(self: *RwLock) HeldWrite {
|
||||||
suspend |handle| {
|
suspend {
|
||||||
// TODO explicitly put this memory in the coroutine frame #1194
|
// TODO explicitly put this memory in the coroutine frame #1194
|
||||||
var my_tick_node = Loop.NextTickNode{
|
var my_tick_node = Loop.NextTickNode{
|
||||||
.data = handle,
|
.data = @handle(),
|
||||||
.prev = undefined,
|
.prev = undefined,
|
||||||
.next = undefined,
|
.next = undefined,
|
||||||
};
|
};
|
||||||
@ -231,8 +231,8 @@ test "std.event.RwLock" {
|
|||||||
|
|
||||||
async fn testLock(loop: *Loop, lock: *RwLock) void {
|
async fn testLock(loop: *Loop, lock: *RwLock) void {
|
||||||
// TODO explicitly put next tick node memory in the coroutine frame #1194
|
// TODO explicitly put next tick node memory in the coroutine frame #1194
|
||||||
suspend |p| {
|
suspend {
|
||||||
resume p;
|
resume @handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
var read_nodes: [100]Loop.NextTickNode = undefined;
|
var read_nodes: [100]Loop.NextTickNode = undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user