1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_Task.h 4 5 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 24252 $ 14 *---------------------------------------------------------------------------*/ 15 16 /*! @file 17 @brief Task に関する API の宣言 18 19 このファイル内の記述は将来的に大幅に変更される可能性があります。 20 直接使わないでください。 21 22 @deprecated 23 24 :include nn/os.h 25 */ 26 27 #ifndef NN_OS_OS_TASK_H_ 28 #define NN_OS_OS_TASK_H_ 29 30 #include <nn/os/os_Synchronization.h> 31 #include <nn/fnd/fnd_Queue.h> 32 #include <nn/util/util_NonCopyable.h> 33 34 #ifdef __cplusplus 35 36 namespace nn { namespace os { 37 38 39 /* 40 @brief タスクを表すクラスです。 41 42 :private 43 44 */ 45 class ITask 46 { 47 public: 48 virtual void Invoke() = 0; ~ITask()49 virtual ~ITask() {} 50 }; 51 52 /* 53 @brief キューイングできるタスククラスです。 54 55 :private 56 */ 57 class QueueableTask : public nn::fnd::IntrusiveQueue<QueueableTask>::Item, public ITask 58 { 59 public: 60 /* 61 @brief プールスレッドで実行される処理です。 62 63 @return 無し。 64 */ 65 virtual void Invoke() = 0; 66 }; 67 68 /* 69 @brief キューイングできる同期タスククラスです。 70 71 :private 72 */ 73 class QueueableWaitTask : private QueueableTask 74 { 75 public: 76 /*! 77 @brief 同期スレッドで同期待ちを行うオブジェクトです。 78 79 @return 無し。 80 */ 81 virtual nn::os::WaitObject* GetWaitObject() = 0; 82 AsNonWaitableTask()83 QueueableTask* AsNonWaitableTask() { return this; } 84 85 friend class IWaitTaskInvoker; 86 }; 87 88 class ITaskInvoker 89 { 90 public: 91 virtual void AddTask(QueueableTask* task) = 0; ~ITaskInvoker()92 virtual ~ITaskInvoker() {} 93 // TODO: 優先度の設定など 94 }; 95 96 class IWaitTaskInvoker : public ITaskInvoker 97 { 98 public: 99 virtual void AddWaitTask(QueueableWaitTask* task) = 0; 100 protected: GetWaitTaskPointer(QueueableTask * p)101 static QueueableWaitTask* GetWaitTaskPointer(QueueableTask* p) { return static_cast<QueueableWaitTask*>(p); } 102 }; 103 104 }} 105 106 #endif 107 108 #endif // NN_OS_OS_THREADPOOL_H_ 109