-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: File watch events refactor #4247
Conversation
Export watch_file, as this is the easiest API entry point between FileMonitor and PollingFileMonitor. Fix _uv_hook_fseventscb such that the condition is notified even if no callback is in the monitor. Also fix the value sent to notify() to match the expected return value in wait(). Fix watch_poll default callback.
writable::Bool | ||
timeout::Bool | ||
end | ||
FDEvent() = FDEvent(false, false, false) |
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 think I'd prefer if these used a single integer flags field to store the flag state and provide accessor functions. This is a place where having bit fields like C would be really nice since we could get both at the same time.
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.
so, define functions like readable(f::FDEvent) = f.flags[1]
, etc.?
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.
That's kind of what I was thinking, but input from @JeffBezanson, @loladiro, @vtjnash & co. would be helpful. This is kind of a taste thing – for APIs like this I tend to favor a more C-like style than is traditional in other high-level languages.
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.
seems like we need @enum_mask
#2988 (with a better names) :)
|
Ok, here it is with integer flag fields and accessors. One thing I couldn't figure out: I wanted to wrap the const definitions and accessors ( |
I definitely think I prefer that. Would be good to get some feedback from @loladiro, @vtjnash & @JeffBezanson. |
I disagree. There's no need to manipulate integer flags so much when they are purely a detail of how the underlying C function needs to be called. I'd rather not export 3 new function names just to access specific bit fields that the user doesn't need to know about. I wrote a version of it here: 146d391, on top of Blake's changes. It requires fewer definitions and fewer exports. |
The user shouldn't have to know the specifics of how the bit fields are implemented, but we do want users to be able to write callback functions that accept these event types as inputs, and to use the results of
or whether that last line should look like
Both look fine to me. In either case, we probably need to export the new event types. |
I would err on the side of minimizing the number of exported names. Exporting the event types might also be optional, since you can check (FWIW I have a similar objection to the methods of |
@JeffBezanson Sure, but it seems odd to expect users to write a callback accepting I don't have a strong preference on fieldnames vs. accessor methods, so whatever you guys decide is fine with me. |
This whole API strikes me as a bit clunky, but maybe that's just the nature of the beast :-\ |
This refactors out the
UV_READABLE
andUV_WRITABLE
constants so that they no longer need to be imported. Instead, there are two new typesFileEvent
andFDEvent
. The callback parameter order has also been shuffled so thatstatus
is always the last argument.Note, the first few commits are the same as #4210.