fixups from the merge
This commit is contained in:
parent
65140b2fba
commit
7f6e97cb26
@ -694,8 +694,8 @@ async fn asyncFmtMain(
|
||||
flags: *const Args,
|
||||
color: errmsg.Color,
|
||||
) FmtError!void {
|
||||
suspend |p| {
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
// Things we need to make event-based:
|
||||
// * 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.
|
||||
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
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
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{
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
.data = my_handle,
|
||||
.data = @handle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
suspend |_| {
|
||||
suspend {
|
||||
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);
|
||||
|
||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
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{
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
.data = my_handle,
|
||||
.data = @handle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
suspend |_| {
|
||||
suspend {
|
||||
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 {
|
||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
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{
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
.data = my_handle,
|
||||
.data = @handle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
suspend |_| {
|
||||
suspend {
|
||||
loop.linuxFsRequest(&req_node);
|
||||
}
|
||||
|
||||
@ -223,10 +214,8 @@ pub async fn openReadWrite(
|
||||
mode: os.File.Mode,
|
||||
) os.File.OpenError!os.FileHandle {
|
||||
// workaround for https://github.com/ziglang/zig/issues/1194
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
const path_with_null = try std.cstr.addNullByte(loop.allocator, path);
|
||||
@ -247,13 +236,13 @@ pub async fn openReadWrite(
|
||||
.TickNode = event.Loop.NextTickNode{
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
.data = my_handle,
|
||||
.data = @handle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
suspend |_| {
|
||||
suspend {
|
||||
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.
|
||||
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
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
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{
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
.data = my_handle,
|
||||
.data = @handle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
suspend |_| {
|
||||
suspend {
|
||||
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 {
|
||||
// TODO https://github.com/ziglang/zig/issues/1194
|
||||
var my_handle: promise = undefined;
|
||||
suspend |p| {
|
||||
my_handle = p;
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
var watch = Watch{
|
||||
.putter = my_handle,
|
||||
.putter = @handle(),
|
||||
.channel = channel,
|
||||
};
|
||||
out_watch.* = &watch;
|
||||
|
@ -98,7 +98,7 @@ pub const Lock = struct {
|
||||
var my_tick_node = Loop.NextTickNode.init(@handle());
|
||||
|
||||
errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire
|
||||
suspend |_| {
|
||||
suspend {
|
||||
self.queue.put(&my_tick_node);
|
||||
|
||||
// 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 {
|
||||
_ = @atomicRmw(usize, &self.reader_lock_count, AtomicRmwOp.Add, 1, AtomicOrder.SeqCst);
|
||||
|
||||
suspend |handle| {
|
||||
suspend {
|
||||
// TODO explicitly put this memory in the coroutine frame #1194
|
||||
var my_tick_node = Loop.NextTickNode{
|
||||
.data = handle,
|
||||
.data = @handle(),
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
};
|
||||
@ -130,10 +130,10 @@ pub const RwLock = struct {
|
||||
}
|
||||
|
||||
pub async fn acquireWrite(self: *RwLock) HeldWrite {
|
||||
suspend |handle| {
|
||||
suspend {
|
||||
// TODO explicitly put this memory in the coroutine frame #1194
|
||||
var my_tick_node = Loop.NextTickNode{
|
||||
.data = handle,
|
||||
.data = @handle(),
|
||||
.prev = undefined,
|
||||
.next = undefined,
|
||||
};
|
||||
@ -231,8 +231,8 @@ test "std.event.RwLock" {
|
||||
|
||||
async fn testLock(loop: *Loop, lock: *RwLock) void {
|
||||
// TODO explicitly put next tick node memory in the coroutine frame #1194
|
||||
suspend |p| {
|
||||
resume p;
|
||||
suspend {
|
||||
resume @handle();
|
||||
}
|
||||
|
||||
var read_nodes: [100]Loop.NextTickNode = undefined;
|
||||
|
Loading…
x
Reference in New Issue
Block a user