MCPcopy Create free account
hub / github.com/Kistler-Group/sdbus-cpp / onSdInternalEvent

Method onSdInternalEvent

src/Connection.cpp:411–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411int Connection::onSdInternalEvent(sd_event_source */*s*/, int /*fd*/, uint32_t /*revents*/, void *userdata)
412{
413 auto *connection = static_cast<Connection*>(userdata);
414 assert(connection != nullptr);
415
416 // It's not really necessary to processPendingEvent() here. We just clear the event fd.
417 // The sd-event loop will before the next poll call prepare callbacks for all event sources,
418 // including I/O bus fd. This will get up-to-date poll timeout, which will be zero if there
419 // are pending D-Bus messages in the read queue, which will immediately wake up next poll
420 // and go to onSdIoEvent() handler, which calls processPendingEvent(). Viola.
421 // For external event loops that only have access to public sdbus-c++ API, processPendingEvent()
422 // is the only option to clear event fd (it comes at a little extra cost but on the other hand
423 // the solution is simpler for clients -- we don't provide an extra method for just clearing
424 // the event fd. There is one method for both fd's -- and that's processPendingEvent().
425
426 // Kept here so that potential readers know what to do in their custom external event loops.
427 //(void)connection->processPendingEvent();
428
429 connection->eventFd_.clear();
430
431 return 1;
432}
433
434int Connection::onSdEventPrepare(sd_event_source */*s*/, void *userdata)
435{

Callers

nothing calls this directly

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected