2
* Copyright Andrey Semashev 2007 - 2013.
3
* Distributed under the Boost Software License, Version 1.0.
4
* (See accompanying file LICENSE_1_0.txt or copy at
5
* http://www.boost.org/LICENSE_1_0.txt)
8
* \file detail/event.hpp
9
* \author Andrey Semashev
13
#ifndef BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
14
#define BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
16
#include <boost/log/detail/config.hpp>
18
#ifdef BOOST_LOG_HAS_PRAGMA_ONCE
22
#ifndef BOOST_LOG_NO_THREADS
24
#if defined(BOOST_THREAD_PLATFORM_PTHREAD)
25
# if defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES + 0) > 0
26
# if defined(__GNUC__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
27
# include <semaphore.h>
28
# include <boost/cstdint.hpp>
29
# define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE
32
#elif defined(BOOST_THREAD_PLATFORM_WIN32)
33
# include <boost/cstdint.hpp>
34
# define BOOST_LOG_EVENT_USE_WINAPI
37
#if !defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE) && !defined(BOOST_LOG_EVENT_USE_WINAPI)
38
# include <boost/thread/mutex.hpp>
39
# include <boost/thread/condition_variable.hpp>
40
# define BOOST_LOG_EVENT_USE_BOOST_CONDITION
43
#include <boost/log/detail/header.hpp>
47
BOOST_LOG_OPEN_NAMESPACE
51
#if defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE)
56
boost::uint32_t m_state;
60
//! Default constructor
61
BOOST_LOG_API sem_based_event();
63
BOOST_LOG_API ~sem_based_event();
65
//! Waits for the object to become signalled
66
BOOST_LOG_API void wait();
67
//! Sets the object to a signalled state
68
BOOST_LOG_API void set_signalled();
72
sem_based_event(sem_based_event const&);
73
sem_based_event& operator= (sem_based_event const&);
76
typedef sem_based_event event;
78
#elif defined(BOOST_LOG_EVENT_USE_WINAPI)
80
class winapi_based_event
83
boost::uint32_t m_state;
87
//! Default constructor
88
BOOST_LOG_API winapi_based_event();
90
BOOST_LOG_API ~winapi_based_event();
92
//! Waits for the object to become signalled
93
BOOST_LOG_API void wait();
94
//! Sets the object to a signalled state
95
BOOST_LOG_API void set_signalled();
99
winapi_based_event(winapi_based_event const&);
100
winapi_based_event& operator= (winapi_based_event const&);
103
typedef winapi_based_event event;
110
boost::mutex m_mutex;
111
boost::condition_variable m_cond;
115
//! Default constructor
116
BOOST_LOG_API generic_event();
118
BOOST_LOG_API ~generic_event();
120
//! Waits for the object to become signalled
121
BOOST_LOG_API void wait();
122
//! Sets the object to a signalled state
123
BOOST_LOG_API void set_signalled();
126
// Copying prohibited
127
generic_event(generic_event const&);
128
generic_event& operator= (generic_event const&);
131
typedef generic_event event;
137
BOOST_LOG_CLOSE_NAMESPACE // namespace log
141
#include <boost/log/detail/footer.hpp>
143
#endif // BOOST_LOG_NO_THREADS
145
#endif // BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_