1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: ut_Lock.h 4 5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain proprietary 8 information of Nintendo and/or its licensed developers and are protected by 9 national and international copyright laws. They may not be disclosed to third 10 parties or copied or duplicated in any form, in whole or in part, without the 11 prior written consent of Nintendo. 12 13 The content herein is highly confidential and should be handled accordingly. 14 15 $Revision: $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_UT_LOCK_H_ 19 #define NW_UT_LOCK_H_ 20 21 #ifdef NW_PLATFORM_CTR 22 #include <nn/os/os_Mutex.h> 23 #else 24 #include <nn/os/ipc/os_Mutex.h> 25 #endif 26 27 #include <nw/types.h> 28 #include <nw/config.h> 29 #include <nw/ut/ut_Inlines.h> 30 #include <nw/os/os_Mutex.h> 31 #include <nw/ut/ut_Preprocessor.h> 32 33 namespace nw { 34 namespace ut { 35 36 namespace internal { 37 38 template<typename Type> 39 class AutoLock 40 { 41 private: 42 NW_DISALLOW_COPY_AND_ASSIGN(AutoLock); 43 44 public: 45 // コンストラクタでロックを行う AutoLock(Type & lockObj)46 AutoLock(Type& lockObj) : m_LockObj(lockObj) 47 { 48 m_LockObj.Lock(); 49 } 50 51 // デストラクタでアンロックを行う ~AutoLock()52 ~AutoLock() 53 { 54 m_LockObj.Unlock(); 55 } 56 57 private: 58 Type& m_LockObj; 59 }; 60 61 } /* namespace internal */ 62 63 typedef internal::AutoLock<nw::os::LockObject> AutoMutexLock; 64 65 } /* namespace ut */ 66 } /* namespace nw */ 67 68 #endif // NW_UT_LOCK_H_ 69