-
Notifications
You must be signed in to change notification settings - Fork 50
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
libflux: add flux_watcher_is_active() #6436
Conversation
Problem: reactor.[ch] do not conform to modern project coding style norms. Break long parameter lists to one per line.
Problem: include order in libflux is fragile. Older files in libflux and related subdirectories tend to include the local and libflux headers that they use but not <flux/core.h>. This makes them fragile when include dependencies change. Reorganize on the following principles: - Move popular "convenience" typedefs to types.h (first in flux.h) - Drop flux include directives from headers that are included by flux.h - Replace flux include directives in other files with <flux/core.h> - Use consistent grouping of include directives and vertical spacing
Problem: flux_set_reactor() and flux_get_reactor() are part of the reactor class but they really belong in the handle one. Move them.
41f1cda
to
9aa1db6
Compare
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.
This turned out to be very nice cleanup! Nice!
@@ -177,37 +177,6 @@ void flux_stat_watcher_get_rstat (flux_watcher_t *w, | |||
struct stat *stat, | |||
struct stat *prev); | |||
|
|||
/* Custom watcher construction functions: |
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.
commit message typo: reslient.
@@ -104,7 +104,11 @@ static void test_fd (flux_reactor_t *reactor) | |||
w = flux_fd_watcher_create (reactor, fd[1], FLUX_POLLOUT, fdwriter, NULL); | |||
ok (r != NULL && w != NULL, | |||
"fd: reader and writer created"); | |||
ok (!flux_watcher_is_active (r), |
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.
Small note: In the commit message:
Add a todo for periodic watchers, which do not seem to follow this rule.
I'm probably missing it, but it seems like the periodic watcher is being tested and I didn't see a todo.
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.
Whoops yeah. I'll fix that and also add a test for the "buffer watchers" which I missed.
Problem: adding operation to 'struct watcher_ops' breaks ABI. Drop that struct and associated functions from the public API. There are no known watcher implementations outside of flux-core, and these functions are undocumented. We can re-publish this part of the API when there is demand, and take more care to make it it resilient to change (e.g. adding padding to the struct) at that time. Update one user to include the private header. Fixes flux-framework#6433
Problem: the functions for incref/decref on the reactor are private, but we may need to move flux_watcher_create(), one of its users, out of reactor.c. Rename those functions and make them public: flux_reactor_incref() flux_reactor_decref()
Problem: flux_watcher_create(), flux_watcher_get_data(), flux_watcher_get_ops() are effectively private but their symbols are visible in the libflux-core.so shared library. Drop the flux_ prefix so they are no longer exported. To minimize change, just inline these small functions in the reactor_private.h header. Update users.
Problem: private header is prepped for C++ use but there is no C++ in core. Drop extern "C" declaration.
Problem: There is no way to test if a flux_watcher_t is stopped or started. Add flux_watcher_is_active(3). If a watcher implements ops->is_active() this returns the boolean result, otherwise it returns false. Add the ops->is_active() callback to all watcher implementations. Fixes flux-framework#4156
Problem: There are no unit tests for flux_watcher_is_active(3). Ensure flux_watcher_is_active() returns false before a watcher is started, and true afterwards.
Problem: flux_watcher_is_active(3) is not documented. Add it to flux_watcher_start.rst.
Fixed the commit message issues, added tests for zmq watcher and buffer watchers, and added a missing issue reference. I'll set MWP, thanks! |
This reworks @grondo's withdrawn PR to use the method discussed in #4156.
It removes the following functions from the public API:
flux_watcher_create()
flux_watcher_get_data()
flux_watcher_get_ops()
Note that #6316 broke this ABI without us noticing, two releases ago. It seemed better to just remove these functions for now than try to make the ABI more robust to change when we don't think anybody actually needs it.
There is some gratuitous cleanup of libflux includes, because I repeatedly found myself dealing with circular dependencies. That could be split off to another PR if desired.