~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to libs/boost-lib/boost/detail/lwm_win32_cs.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
2
 
#define BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
3
 
 
4
 
// MS compatible compilers support #pragma once
5
 
 
6
 
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7
 
# pragma once
8
 
#endif
9
 
 
10
 
//
11
 
//  boost/detail/lwm_win32_cs.hpp
12
 
//
13
 
//  Copyright (c) 2002, 2003 Peter Dimov
14
 
//
15
 
// Distributed under the Boost Software License, Version 1.0. (See
16
 
// accompanying file LICENSE_1_0.txt or copy at
17
 
// http://www.boost.org/LICENSE_1_0.txt)
18
 
//
19
 
 
20
 
#ifdef BOOST_USE_WINDOWS_H
21
 
#  include <windows.h>
22
 
#endif
23
 
 
24
 
namespace boost
25
 
{
26
 
 
27
 
namespace detail
28
 
{
29
 
 
30
 
#ifndef BOOST_USE_WINDOWS_H
31
 
 
32
 
struct CRITICAL_SECTION
33
 
{
34
 
    struct critical_section_debug * DebugInfo;
35
 
    long LockCount;
36
 
    long RecursionCount;
37
 
    void * OwningThread;
38
 
    void * LockSemaphore;
39
 
#if defined(_WIN64)
40
 
    unsigned __int64 SpinCount;
41
 
#else
42
 
    unsigned long SpinCount;
43
 
#endif
44
 
};
45
 
 
46
 
extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
47
 
extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
48
 
extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
49
 
extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
50
 
 
51
 
#endif // #ifndef BOOST_USE_WINDOWS_H
52
 
 
53
 
class lightweight_mutex
54
 
{
55
 
private:
56
 
 
57
 
    CRITICAL_SECTION cs_;
58
 
 
59
 
    lightweight_mutex(lightweight_mutex const &);
60
 
    lightweight_mutex & operator=(lightweight_mutex const &);
61
 
 
62
 
public:
63
 
 
64
 
    lightweight_mutex()
65
 
    {
66
 
        InitializeCriticalSection(&cs_);
67
 
    }
68
 
 
69
 
    ~lightweight_mutex()
70
 
    {
71
 
        DeleteCriticalSection(&cs_);
72
 
    }
73
 
 
74
 
    class scoped_lock;
75
 
    friend class scoped_lock;
76
 
 
77
 
    class scoped_lock
78
 
    {
79
 
    private:
80
 
 
81
 
        lightweight_mutex & m_;
82
 
 
83
 
        scoped_lock(scoped_lock const &);
84
 
        scoped_lock & operator=(scoped_lock const &);
85
 
 
86
 
    public:
87
 
 
88
 
        explicit scoped_lock(lightweight_mutex & m): m_(m)
89
 
        {
90
 
            EnterCriticalSection(&m_.cs_);
91
 
        }
92
 
 
93
 
        ~scoped_lock()
94
 
        {
95
 
            LeaveCriticalSection(&m_.cs_);
96
 
        }
97
 
    };
98
 
};
99
 
 
100
 
} // namespace detail
101
 
 
102
 
} // namespace boost
103
 
 
104
 
#endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED