diff options
author | William A. Kennington III <wak@google.com> | 2018-10-19 15:56:09 -0700 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-12-06 14:00:26 +0000 |
commit | 223c40931e4f413431ab2f84d92c5f404e2d9cf2 (patch) | |
tree | fae46d08b8e00a2f0d34b62638ab090cd3831c3d /src/sdevent/source.hpp | |
parent | ecf8910c014b94c688d08fa856cd22ec365583fa (diff) | |
download | phosphor-dbus-monitor-223c40931e4f413431ab2f84d92c5f404e2d9cf2.tar.gz phosphor-dbus-monitor-223c40931e4f413431ab2f84d92c5f404e2d9cf2.zip |
sdevent: Remove in favor of sdeventplus
This change removes the one off sd-event wrapper from the project and
uses the openbmc wide sdeventplus library.
Change-Id: I8e042f875d06082e15606c7191a8073974f93990
Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'src/sdevent/source.hpp')
-rw-r--r-- | src/sdevent/source.hpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/src/sdevent/source.hpp b/src/sdevent/source.hpp deleted file mode 100644 index 6b20c29..0000000 --- a/src/sdevent/source.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#pragma once - -#include <systemd/sd-event.h> - -#include <chrono> -#include <memory> - -// TODO: openbmc/openbmc#1720 - add error handling for sd_event API failures - -namespace sdevent -{ -namespace source -{ - -using SourcePtr = sd_event_source*; - -namespace details -{ - -/** @brief unique_ptr functor to release a source reference. */ -struct SourceDeleter -{ - void operator()(sd_event_source* ptr) const - { - deleter(ptr); - } - - decltype(&sd_event_source_unref) deleter = sd_event_source_unref; -}; - -/* @brief Alias 'source' to a unique_ptr type for auto-release. */ -using source = std::unique_ptr<sd_event_source, SourceDeleter>; - -} // namespace details - -/** @class Source - * @brief Provides C++ bindings to the sd_event_source* functions. - */ -class Source -{ - public: - /* Define all of the basic class operations: - * Not allowed: - * - Default constructor to avoid nullptrs. - * - Copy operations due to internal unique_ptr. - * Allowed: - * - Move operations. - * - Destructor. - */ - Source() = delete; - Source(const Source&) = delete; - Source& operator=(const Source&) = delete; - Source(Source&&) = default; - Source& operator=(Source&&) = default; - ~Source() = default; - - /** @brief Conversion constructor from 'SourcePtr'. - * - * Increments ref-count of the source-pointer and releases it - * when done. - */ - explicit Source(SourcePtr s) : src(sd_event_source_ref(s)) - { - } - - /** @brief Constructor for 'source'. - * - * Takes ownership of the source-pointer and releases it when done. - */ - Source(SourcePtr s, std::false_type) : src(s) - { - } - - /** @brief Check if source contains a real pointer. (non-nullptr). */ - explicit operator bool() const - { - return bool(src); - } - - /** @brief Test whether or not the source can generate events. */ - auto enabled() - { - int enabled; - sd_event_source_get_enabled(src.get(), &enabled); - return enabled; - } - - /** @brief Allow the source to generate events. */ - void enable(int enable) - { - sd_event_source_set_enabled(src.get(), enable); - } - - /** @brief Set the expiration on a timer source. */ - void setTime(const std::chrono::steady_clock::time_point& expires) - { - using namespace std::chrono; - auto epoch = expires.time_since_epoch(); - auto time = duration_cast<microseconds>(epoch); - sd_event_source_set_time(src.get(), time.count()); - } - - /** @brief Get the expiration on a timer source. */ - auto getTime() - { - using namespace std::chrono; - uint64_t usec; - sd_event_source_get_time(src.get(), &usec); - microseconds d(usec); - return steady_clock::time_point(d); - } - - private: - details::source src; -}; -} // namespace source -} // namespace sdevent |