1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/detail/lwm_win32_cs.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,104 @@
1.4 +#ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
1.5 +#define BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
1.6 +
1.7 +// MS compatible compilers support #pragma once
1.8 +
1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.10 +# pragma once
1.11 +#endif
1.12 +
1.13 +//
1.14 +// boost/detail/lwm_win32_cs.hpp
1.15 +//
1.16 +// Copyright (c) 2002, 2003 Peter Dimov
1.17 +//
1.18 +// Distributed under the Boost Software License, Version 1.0. (See
1.19 +// accompanying file LICENSE_1_0.txt or copy at
1.20 +// http://www.boost.org/LICENSE_1_0.txt)
1.21 +//
1.22 +
1.23 +#ifdef BOOST_USE_WINDOWS_H
1.24 +# include <windows.h>
1.25 +#endif
1.26 +
1.27 +namespace boost
1.28 +{
1.29 +
1.30 +namespace detail
1.31 +{
1.32 +
1.33 +#ifndef BOOST_USE_WINDOWS_H
1.34 +
1.35 +struct CRITICAL_SECTION
1.36 +{
1.37 + struct critical_section_debug * DebugInfo;
1.38 + long LockCount;
1.39 + long RecursionCount;
1.40 + void * OwningThread;
1.41 + void * LockSemaphore;
1.42 +#if defined(_WIN64)
1.43 + unsigned __int64 SpinCount;
1.44 +#else
1.45 + unsigned long SpinCount;
1.46 +#endif
1.47 +};
1.48 +
1.49 +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
1.50 +extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
1.51 +extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
1.52 +extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
1.53 +
1.54 +#endif // #ifndef BOOST_USE_WINDOWS_H
1.55 +
1.56 +class lightweight_mutex
1.57 +{
1.58 +private:
1.59 +
1.60 + CRITICAL_SECTION cs_;
1.61 +
1.62 + lightweight_mutex(lightweight_mutex const &);
1.63 + lightweight_mutex & operator=(lightweight_mutex const &);
1.64 +
1.65 +public:
1.66 +
1.67 + lightweight_mutex()
1.68 + {
1.69 + InitializeCriticalSection(&cs_);
1.70 + }
1.71 +
1.72 + ~lightweight_mutex()
1.73 + {
1.74 + DeleteCriticalSection(&cs_);
1.75 + }
1.76 +
1.77 + class scoped_lock;
1.78 + friend class scoped_lock;
1.79 +
1.80 + class scoped_lock
1.81 + {
1.82 + private:
1.83 +
1.84 + lightweight_mutex & m_;
1.85 +
1.86 + scoped_lock(scoped_lock const &);
1.87 + scoped_lock & operator=(scoped_lock const &);
1.88 +
1.89 + public:
1.90 +
1.91 + explicit scoped_lock(lightweight_mutex & m): m_(m)
1.92 + {
1.93 + EnterCriticalSection(&m_.cs_);
1.94 + }
1.95 +
1.96 + ~scoped_lock()
1.97 + {
1.98 + LeaveCriticalSection(&m_.cs_);
1.99 + }
1.100 + };
1.101 +};
1.102 +
1.103 +} // namespace detail
1.104 +
1.105 +} // namespace boost
1.106 +
1.107 +#endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED