/*---------------------------------------------------------------------------* Project: NintendoWare File: os_MutexCTR.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. 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. $Revision: 25116 $ *---------------------------------------------------------------------------*/ #include #include namespace nw { namespace os { namespace internal { //--------------------------------------------------------------------------- //! @brief CTR 用の Mutex の具象クラスです。 //--------------------------------------------------------------------------- class LockObject { public: /* ctor */ LockObject() { m_CriticalSection.Initialize(); } /* dtor */ ~LockObject() { m_CriticalSection.Finalize(); } void Lock() { m_CriticalSection.Enter(); } bool TryLock() { return m_CriticalSection.TryEnter(); } void Unlock() { m_CriticalSection.Leave(); } private: nn::os::CriticalSection m_CriticalSection; }; //--------------------------------------------------------------------------- //! @brief CTR 用の Interrupts の具象クラスです。 //! このクラスは実際には何も処理をおこないません。 //--------------------------------------------------------------------------- class Interrupts { public: static bool Disable() { bool previous = m_Enabled; m_Enabled = false; return previous; } static bool Enable() { bool previous = m_Enabled; m_Enabled = true; return previous; } static bool Restore(bool level) { bool previous = m_Enabled; m_Enabled = level; return previous; } private: static bool m_Enabled; }; } // namespace internal } // namespace os } // namespace nw