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