Skip to content

Commit

Permalink
libflux: refactor reactor/watcher implementation
Browse files Browse the repository at this point in the history
Problem: the reactor and watcher implementations are unnecessarily
exposed and co-mingled.

Split up reactor.c, reactor.h (public), reactor_private.h into:

reactor.c, reactor_private.h
  Only the reactor struct and implementation.
  Add an accessor for the ev_loop, to be used only in watcher_wrap.c

watcher.c, watcher_private.h
  Only the watcher struct and generic "class" implementation.
  Add accessors to avoid exposing watcher struct details to watcher
  implementations.

watcher_wrap.c
  Wrapped libev watcher implementations.
  These now use watcher accessors rather than directly accessing
  the watcher struct.

A public watcher.h header is added to split out the public watcher
interfaces from reactor.h.  This was not strictly necessary, but
reactor.h was a little busy.  Users are still expected to just include
<flux/core.h>.

Update the zmq watcher, flux_t handle watcher, fbuf watchers, and sdbus
watcher to include watcher_private.h and use watcher accessors.

Replacing the inlines in reactor_private.h with actual functions
in watcher.c necessitated linking some executables with
src/common/libflux/watcher.lo.

libev use is now localized to reactor.c and watcher_wrap.c, which should
make transitioning to a new implementation somewhat easier than before.
The code should also be easier to read and navigate.
  • Loading branch information
garlick committed Dec 11, 2024
1 parent bf55981 commit f7d3cec
Show file tree
Hide file tree
Showing 19 changed files with 1,027 additions and 854 deletions.
2 changes: 2 additions & 0 deletions src/cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ flux_start_LDADD = \

flux_job_LDADD = \
$(top_builddir)/src/common/libsubprocess/libsubprocess.la \
$(top_builddir)/src/common/libflux/watcher.lo \
$(top_builddir)/src/shell/libmpir.la \
$(top_builddir)/src/common/libjob/libjob.la \
$(top_builddir)/src/common/libutil/libutil.la \
Expand All @@ -185,6 +186,7 @@ flux_job_LDADD = \

flux_exec_LDADD = \
$(top_builddir)/src/common/libsubprocess/libsubprocess.la \
$(top_builddir)/src/common/libflux/watcher.lo \
$(fluxcmd_ldadd)

flux_terminus_LDADD = \
Expand Down
4 changes: 4 additions & 0 deletions src/common/libflux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fluxcoreinclude_HEADERS = \
handle.h \
connector.h \
reactor.h \
watcher.h \
msg_handler.h \
message.h \
msglist.h \
Expand Down Expand Up @@ -62,6 +63,9 @@ libflux_la_SOURCES = \
connector_local.c \
reactor.c \
reactor_private.h \
watcher.c \
watcher_private.h \
watcher_wrap.c \
hwatcher.c \
msg_handler.c \
message.c \
Expand Down
1 change: 1 addition & 0 deletions src/common/libflux/flux.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "message.h"
#include "handle.h"
#include "reactor.h"
#include "watcher.h"
#include "msg_handler.h"
#include "connector.h"
#include "msglist.h"
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/hwatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "src/common/libutil/errno_safe.h"

#include "reactor_private.h"
#include "watcher_private.h"

struct hwatcher {
flux_watcher_t *fd_w;
Expand Down
Loading

0 comments on commit f7d3cec

Please sign in to comment.