comparison DEPENDENCIES/generic/include/boost/log/detail/event.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 /*
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)
6 */
7 /*!
8 * \file detail/event.hpp
9 * \author Andrey Semashev
10 * \date 24.07.2011
11 */
12
13 #ifndef BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
14 #define BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_
15
16 #include <boost/log/detail/config.hpp>
17
18 #ifdef BOOST_HAS_PRAGMA_ONCE
19 #pragma once
20 #endif
21
22 #ifndef BOOST_LOG_NO_THREADS
23
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
30 # endif
31 # endif
32 #elif defined(BOOST_THREAD_PLATFORM_WIN32)
33 # include <boost/cstdint.hpp>
34 # define BOOST_LOG_EVENT_USE_WINAPI
35 #endif
36
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
41 #endif
42
43 #include <boost/log/detail/header.hpp>
44
45 namespace boost {
46
47 BOOST_LOG_OPEN_NAMESPACE
48
49 namespace aux {
50
51 #if defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE)
52
53 class sem_based_event
54 {
55 private:
56 boost::uint32_t m_state;
57 sem_t m_semaphore;
58
59 public:
60 //! Default constructor
61 BOOST_LOG_API sem_based_event();
62 //! Destructor
63 BOOST_LOG_API ~sem_based_event();
64
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();
69
70 // Copying prohibited
71 BOOST_DELETED_FUNCTION(sem_based_event(sem_based_event const&))
72 BOOST_DELETED_FUNCTION(sem_based_event& operator= (sem_based_event const&))
73 };
74
75 typedef sem_based_event event;
76
77 #elif defined(BOOST_LOG_EVENT_USE_WINAPI)
78
79 class winapi_based_event
80 {
81 private:
82 boost::uint32_t m_state;
83 void* m_event;
84
85 public:
86 //! Default constructor
87 BOOST_LOG_API winapi_based_event();
88 //! Destructor
89 BOOST_LOG_API ~winapi_based_event();
90
91 //! Waits for the object to become signalled
92 BOOST_LOG_API void wait();
93 //! Sets the object to a signalled state
94 BOOST_LOG_API void set_signalled();
95
96 // Copying prohibited
97 BOOST_DELETED_FUNCTION(winapi_based_event(winapi_based_event const&))
98 BOOST_DELETED_FUNCTION(winapi_based_event& operator= (winapi_based_event const&))
99 };
100
101 typedef winapi_based_event event;
102
103 #else
104
105 class generic_event
106 {
107 private:
108 boost::mutex m_mutex;
109 boost::condition_variable m_cond;
110 bool m_state;
111
112 public:
113 //! Default constructor
114 BOOST_LOG_API generic_event();
115 //! Destructor
116 BOOST_LOG_API ~generic_event();
117
118 //! Waits for the object to become signalled
119 BOOST_LOG_API void wait();
120 //! Sets the object to a signalled state
121 BOOST_LOG_API void set_signalled();
122
123 // Copying prohibited
124 BOOST_DELETED_FUNCTION(generic_event(generic_event const&))
125 BOOST_DELETED_FUNCTION(generic_event& operator= (generic_event const&))
126 };
127
128 typedef generic_event event;
129
130 #endif
131
132 } // namespace aux
133
134 BOOST_LOG_CLOSE_NAMESPACE // namespace log
135
136 } // namespace boost
137
138 #include <boost/log/detail/footer.hpp>
139
140 #endif // BOOST_LOG_NO_THREADS
141
142 #endif // BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_