#ifndef __SHAREDSEMAPHORE_POSIX_H_ #define __SHAREDSEMAPHORE_POSIX_H_ #ifdef __cplusplus #include #include #include #include #include "icsneo/api/eventmanager.h" namespace icsneo { class SharedSemaphore { public: ~SharedSemaphore(); bool open(const std::string& name, bool create = false, unsigned initialCount = 0); bool close(); bool wait(const std::chrono::milliseconds& timeout); bool post(); private: virtual device_eventhandler_t makeEventHandler() { return [](APIEvent::Type type, APIEvent::Severity severity) { EventManager::GetInstance().add(type, severity); }; } std::atomic closing = false; std::atomic waiting = false; device_eventhandler_t report = makeEventHandler(); std::optional mName; std::optional semaphore; std::optional created; }; } #endif // __cplusplus #endif