diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-15 22:30:15 -0400 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-02 20:18:18 +0000 |
commit | 0c9271f0a214d1c6cdce79fdcabc62653038e942 (patch) | |
tree | be9a0889eca87b966dcca62f1dff0a2155eca763 /sdevent | |
parent | e54a98f42006d3298fcfae34c52b70fb70245431 (diff) | |
download | phosphor-fan-presence-0c9271f0a214d1c6cdce79fdcabc62653038e942.tar.gz phosphor-fan-presence-0c9271f0a214d1c6cdce79fdcabc62653038e942.zip |
Add loop exit wrapper
Add a wrapper for sd_event_exit.
Change-Id: Ie08a74cb388e8441683fbf90902cbcb463aa9e6f
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'sdevent')
-rw-r--r-- | sdevent/event.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sdevent/event.hpp b/sdevent/event.hpp index 3e97ce7..9f04dd0 100644 --- a/sdevent/event.hpp +++ b/sdevent/event.hpp @@ -87,6 +87,29 @@ class Event sd_event_loop(evt.get()); } + /** @brief Stop the loop. */ + void exit(int status = 0) + { + auto rc = sd_event_exit(evt.get(), status); + if (rc < 0) + { + phosphor::logging::elog<InternalFailure>(); + } + } + + /** @brief Get the loop exit code. */ + auto getExitStatus() + { + int status; + auto rc = sd_event_get_exit_code(evt.get(), &status); + if (rc < 0) + { + phosphor::logging::elog<InternalFailure>(); + } + + return status; + } + /** @brief Attach to a DBus loop. */ void attach(sdbusplus::bus::bus& bus) { |