~ai.tron/armagetronad/0.4-winlibs-updated

« back to all changes in this revision

Viewing changes to boost/includes/boost/log/detail/event.hpp

  • Committer: Nik K.
  • Date: 2013-11-07 16:58:35 UTC
  • Revision ID: nik.karbaum@gmail.com-20131107165835-kq99jz23drfj4dkh
Forgot to add some files; here they are

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_LOG_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
private:
 
71
    //  Copying prohibited
 
72
    sem_based_event(sem_based_event const&);
 
73
    sem_based_event& operator= (sem_based_event const&);
 
74
};
 
75
 
 
76
typedef sem_based_event event;
 
77
 
 
78
#elif defined(BOOST_LOG_EVENT_USE_WINAPI)
 
79
 
 
80
class winapi_based_event
 
81
{
 
82
private:
 
83
    boost::uint32_t m_state;
 
84
    void* m_event;
 
85
 
 
86
public:
 
87
    //! Default constructor
 
88
    BOOST_LOG_API winapi_based_event();
 
89
    //! Destructor
 
90
    BOOST_LOG_API ~winapi_based_event();
 
91
 
 
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();
 
96
 
 
97
private:
 
98
    //  Copying prohibited
 
99
    winapi_based_event(winapi_based_event const&);
 
100
    winapi_based_event& operator= (winapi_based_event const&);
 
101
};
 
102
 
 
103
typedef winapi_based_event event;
 
104
 
 
105
#else
 
106
 
 
107
class generic_event
 
108
{
 
109
private:
 
110
    boost::mutex m_mutex;
 
111
    boost::condition_variable m_cond;
 
112
    bool m_state;
 
113
 
 
114
public:
 
115
    //! Default constructor
 
116
    BOOST_LOG_API generic_event();
 
117
    //! Destructor
 
118
    BOOST_LOG_API ~generic_event();
 
119
 
 
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();
 
124
 
 
125
private:
 
126
    //  Copying prohibited
 
127
    generic_event(generic_event const&);
 
128
    generic_event& operator= (generic_event const&);
 
129
};
 
130
 
 
131
typedef generic_event event;
 
132
 
 
133
#endif
 
134
 
 
135
} // namespace aux
 
136
 
 
137
BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
138
 
 
139
} // namespace boost
 
140
 
 
141
#include <boost/log/detail/footer.hpp>
 
142
 
 
143
#endif // BOOST_LOG_NO_THREADS
 
144
 
 
145
#endif // BOOST_LOG_DETAIL_EVENT_HPP_INCLUDED_