src/sysc/packages/boost/detail/lwm_win32_cs.hpp

Go to the documentation of this file.
00001 #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
00002 #define BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
00003 
00004 #if _MSC_VER >= 1020
00005 #pragma once
00006 #endif
00007 
00008 //
00009 //  boost/detail/lwm_win32_cs.hpp
00010 //
00011 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
00012 //
00013 //  Permission to copy, use, modify, sell and distribute this software
00014 //  is granted provided this copyright notice appears in all copies.
00015 //  This software is provided "as is" without express or implied
00016 //  warranty, and with no claim as to its suitability for any purpose.
00017 //
00018 
00019 #include <sysc/packages/boost/detail/winapi.hpp>
00020 
00021 namespace boost
00022 {
00023 
00024 namespace detail
00025 {
00026 
00027 class lightweight_mutex
00028 {
00029 private:
00030 
00031     winapi::critical_section cs_;
00032 
00033     lightweight_mutex(lightweight_mutex const &);
00034     lightweight_mutex & operator=(lightweight_mutex const &);
00035 
00036 public:
00037 
00038     lightweight_mutex()
00039     {
00040         winapi::InitializeCriticalSection(&cs_);
00041     }
00042 
00043     ~lightweight_mutex()
00044     {
00045         winapi::DeleteCriticalSection(&cs_);
00046     }
00047 
00048     class scoped_lock;
00049     friend class scoped_lock;
00050 
00051     class scoped_lock
00052     {
00053     private:
00054 
00055         lightweight_mutex & m_;
00056 
00057         scoped_lock(scoped_lock const &);
00058         scoped_lock & operator=(scoped_lock const &);
00059 
00060     public:
00061 
00062         explicit scoped_lock(lightweight_mutex & m): m_(m)
00063         {
00064             winapi::EnterCriticalSection(&m_.cs_);
00065         }
00066 
00067         ~scoped_lock()
00068         {
00069             winapi::LeaveCriticalSection(&m_.cs_);
00070         }
00071     };
00072 };
00073 
00074 } // namespace detail
00075 
00076 } // namespace boost
00077 
00078 #endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED

Generated on Wed Apr 25 13:53:28 2007 for SystemC by  doxygen 1.5.1