-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduce std.event.fs for async file system functions #1294
Conversation
std/event/fs.zig
Outdated
|
||
/// This abstraction helps to close file handles in defer expressions | ||
/// without suspending. Start a CloseOperation before opening a file. | ||
pub const CloseOperation = struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnoordhuis specific question for you: is this necessary? Is there any reason that we shouldn't invoke the close
syscall in a blocking fashion for a file system file descriptor? Note that this is not fclose
where it may do some flushing, this is the actual close syscall.
See line 278 for usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say so. close()
can block if there is still data to write, and may not be immediate on NFS.
* add std.event.RwLock and std.event.RwLocked * std.debug.warn does its printing locked * add std.Mutex, however it's currently implemented as a spinlock * rename std.event.Group.cancelAll to std.event.Group.deinit and change the docs and assumptions. * add std.HashMap.clone
Here's a quick demo of what this branch does: https://youtu.be/b_Pm29crq6Q The stage2 compiler tests still pass for linux, so my goal is now to get this stuff working on MacOS and Windows (the above checkboxes) and then merge. |
Question: is |
Yes. That is #1194. It's an issue with LLVM that we can work around and there are some other considerations. |
Working on darwin branch. Using kqueue(2) for files and FSEvents for directories. |
The file I/O stuff is working, but the fs watching stuff is not yet.
TODO: after 1 event emitted for a deleted file, the file is no longer watched
also fix 2 bugs where the function didn't call allocator.shrink: * std.mem.join * std.os.path.resolve
Yay! Good work! |
checklist
After this I want to implement fs watching because I want to use it in the self hosted compiler.
@bnoordhuis you may be interested in this change since it's the zig equivalent to libuv :-)