/*---------------------------------------------------------------------------* Project: NintendoWare File: os_MutexCTRWIN.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #include #include #include namespace nw { namespace os { namespace internal { //--------------------------------------------------------------------------- //! @brief CTRWIN 用の Mutex の具象クラスです。 //--------------------------------------------------------------------------- class LockObject { public: /* ctor */ LockObject() { nn::os::ipc::InitMutex( &m_Mutex ); } /* dtor */ virtual ~LockObject() { nn::os::ipc::DestroyMutex( m_Mutex ); } virtual void Lock() { nn::os::ipc::LockMutex( m_Mutex ); } virtual bool TryLock() { nn::Result result = nn::os::ipc::TryLockMutex( m_Mutex ); return result.IsSuccess(); } virtual void Unlock() { nn::os::ipc::UnlockMutex( m_Mutex ); } private: nn::os::ipc::Mutex m_Mutex; }; class Interrupts { public: static bool Disable() { return (OS_DisableInterrupts() != FALSE); } static bool Enable() { return (OS_EnableInterrupts() != FALSE); } static bool Restore(bool level) { return (OS_RestoreInterrupts( level? TRUE : FALSE ) != FALSE); } }; } // namespace internal } // namespace os } // namespace nw