1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_TaskThread.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: 31311 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_SND_TASK_THREAD_H_ 19 #define NW_SND_TASK_THREAD_H_ 20 21 #include <nw/snd/snd_ThreadStack.h> 22 23 namespace nw { 24 namespace snd { 25 namespace internal { 26 27 class TaskThread 28 { 29 public: 30 TaskThread(); 31 ~TaskThread(); 32 33 bool Create( s32 priority, ThreadStack& stack ); 34 void Destroy(); 35 IsCreated()36 bool IsCreated() const { return m_IsCreated != 0; } 37 SetPriority(s32 priority)38 void SetPriority( s32 priority ) 39 { 40 m_Thread.ChangePriority( priority ); 41 } 42 TryLock()43 bool TryLock() 44 { 45 return m_CriticalSection.TryEnter(); 46 } Lock()47 void Lock() 48 { 49 m_CriticalSection.Enter(); 50 } Unlock()51 void Unlock() 52 { 53 m_CriticalSection.Leave(); 54 } 55 public: 56 static TaskThread& GetInstance(); 57 58 private: 59 void ThreadProc(); 60 static void ThreadFunc( uptr arg ); 61 62 nn::os::Thread m_Thread; 63 nn::os::CriticalSection m_CriticalSection; 64 volatile bool m_IsFinished; 65 bool m_IsCreated; 66 }; 67 68 } // namespace nw::snd::internal 69 } // namespace nw::snd 70 } // namespace nw 71 72 73 #endif /* NW_SND_TASK_THREAD_H_ */ 74 75