/*---------------------------------------------------------------------------* Project: NintendoWare File: os_MutexCTRWIN.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 #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