25 #ifndef LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H 26 #define LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H 30 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 36 #if (defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \ 37 && defined (LOG4CPLUS_BUILD_DLL)) \ 38 || defined (LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL) 41 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 45 #define LOG4CPLUS_THROW_RTE(msg) \ 46 do { log4cplus::thread::impl::syncprims_throw_exception (msg, __FILE__, \ 47 __LINE__); } while (0) 56 char const *
const file,
int line);
98 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 100 , val ((std::min) (max, initial))
114 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 115 std::lock_guard<std::mutex> guard (mtx);
118 LOG4CPLUS_THROW_RTE (
"Semaphore::unlock(): val >= max");
130 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 131 std::unique_lock<std::mutex> guard (mtx);
134 LOG4CPLUS_THROW_RTE (
"Semaphore::unlock(): val > max");
142 LOG4CPLUS_THROW_RTE (
"Semaphore::unlock(): val >= max");
153 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 169 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 170 std::unique_lock<std::mutex> guard (mtx);
183 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 184 std::unique_lock<std::mutex> guard (mtx);
188 unsigned prev_count = sigcount;
193 while (prev_count == sigcount);
203 #if defined (LOG4CPLUS_SINGLE_THREADED) 207 std::unique_lock<std::mutex> guard (mtx);
211 unsigned prev_count = sigcount;
213 std::chrono::steady_clock::time_point
const wait_until_time
215 + std::chrono::milliseconds (msec);
219 int ret = static_cast<int>(
220 cv.wait_until (guard, wait_until_time));
223 case static_cast<int>(std::cv_status::no_timeout):
226 case static_cast<int>(std::cv_status::timeout):
232 LOG4CPLUS_THROW_RTE (
"ManualResetEvent::timed_wait");
235 while (prev_count == sigcount);
247 #if ! defined (LOG4CPLUS_SINGLE_THREADED) 248 std::lock_guard<std::mutex> guard (mtx);
315 #endif // LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL 317 #endif // LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H
#define LOG4CPLUS_THREADED(x)
ManualResetEvent(bool=false)
bool timed_wait(unsigned long msec) const
#define LOG4CPLUS_ATTRIBUTE_NORETURN
LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN syncprims_throw_exception(char const *const msg, char const *const file, int line)
Semaphore(unsigned max, unsigned initial)
#define LOG4CPLUS_UNLIKELY(cond)
#define LOG4CPLUS_INLINE_EXPORT