1

The sd-event is a event loop framework similar to libev, libuv, libevent, etc, I need to implement libev event loop for monitoring services. All the man pages I can find talk about the use of sd_bus_get_fd(), sd_bus_get_events() and sd_bus_get_timeout(), for example, on this page. Does anyone have a project example for using those three functions?

1
  • I noticed this issue sometime ago because I was interested in sd-bus with libev. I work on a project that uses libev but 99% of the project code calls wrappers on top of libev. I am currently working on this PR in github, which perhaps you or others can get hints on sd-bus + libev: github.com/flux-framework/flux-core/pull/3864 Commented Jan 11, 2022 at 22:36

1 Answer 1

0

Don't have anything for libev but for libevent + sdbus , it goes something like this

 //Global static sd_bus *bus = NULL; static struct event_base *base = NULL; void bus_process(evutil_socket_t fd, short what, void *arg) { sd_bus_process(bus, NULL); } void main() { sd_bus_default_system(&bus); sd_bus_request_name(bus, BUS_NAME, 0); int fd = 0; int events = 0; uint64_t usec; struct event *ev_read; base = event_base_new() fd = sd_bus_get_fd(bus); events = sd_bus_get_events(bus); sd_bus_get_timeout(bus, &usec); evutil_make_socket_nonblocking(fd); ev_read = event_new(base, fd, EV_READ|EV_PERSIST, bus_process, NULL); event_add(ev_read, NULL); event_base_dispatch(base); // wont get here, loop is now running and processing return; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.