.. _program_listing_file__tmp_ws_src_ecl_core_ecl_ipc_include_ecl_ipc_semaphore_pos.hpp: Program Listing for File semaphore_pos.hpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ecl_core/ecl_ipc/include/ecl/ipc/semaphore_pos.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef ECL_IPC_SEMAPHORE_POS_HPP_ #define ECL_IPC_SEMAPHORE_POS_HPP_ /***************************************************************************** ** Platform Check *****************************************************************************/ #include #if defined(ECL_IS_POSIX) #include #ifdef _POSIX_SEMAPHORES #if _POSIX_SEMAPHORES > 0 /***************************************************************************** ** Ecl Functionality Defines *****************************************************************************/ #ifndef ECL_HAS_POSIX_SEMAPHORES #define ECL_HAS_POSIX_SEMAPHORES #endif #ifndef ECL_HAS_SEMAPHORES #define ECL_HAS_SEMAPHORES #endif /***************************************************************************** ** Includes *****************************************************************************/ #include #include #include #include /* For O_* constants */ #include #include /***************************************************************************** ** Namespaces *****************************************************************************/ namespace ecl { /***************************************************************************** ** Forward Declarations *****************************************************************************/ class Semaphore; #ifdef ECL_HAS_EXCEPTIONS namespace ipc { /***************************************************************************** ** Semaphore Exceptions *****************************************************************************/ ECL_LOCAL ecl::StandardException openSemaphoreException(const char* loc ); ECL_LOCAL ecl::StandardException tryLockSemaphoreException(const char* loc); } // namespace ipc #endif /* ECL_HAS_EXCEPTIONS */ /***************************************************************************** ** Semaphores *****************************************************************************/ class ECL_PUBLIC Semaphore { public: /********************* ** C&D's **********************/ Semaphore(); Semaphore(const std::string& string_id); virtual ~Semaphore(); /********************* ** Locking **********************/ void lock(); void unlock(); bool trylock(); bool trylock( const Duration &timeout ); private: std::string name; sem_t* semaphore; int count(); }; } // namespace ecl #endif /* _POSIX_SEMAPHORES > 0 */ #endif /* _POSIX_SEMAPHORES */ #endif /* ECL_IS_POSIX */ #endif /* ECL_IPC_SEMAPHORE_POS_HPP_ */