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     virtual void Invoke() = 0;
48 };
49 
50 /*!
51     @brief  キューイングできるタスククラスです。
52 
53     :private
54 */
55 class QueueableTask : public nn::fnd::IntrusiveQueue<QueueableTask>::Item, public ITask
56 {
57 public:
58     /*!
59         @brief      プールスレッドで実行される処理です。
60 
61         @return     無し。
62      */
63     virtual void Invoke() = 0;
64 };
65 
66 /*!
67     @brief  キューイングできる同期タスククラスです。
68 
69     :private
70 */
71 class QueueableWaitTask : private QueueableTask
72 {
73 public:
74     /*!
75         @brief      同期スレッドで同期待ちを行うオブジェクトです。
76 
77         @return     無し。
78      */
79     virtual nn::os::WaitObject* GetWaitObject() = 0;
80 
AsNonWaitableTask()81     QueueableTask* AsNonWaitableTask() { return this; }
82 
83     friend class IWaitTaskInvoker;
84 };
85 
86 class ITaskInvoker
87 {
88 public:
89     virtual void AddTask(QueueableTask* task) = 0;
90     // TODO: 優先度の設定など
91 };
92 
93 class IWaitTaskInvoker : public ITaskInvoker
94 {
95 public:
96     virtual void AddWaitTask(QueueableWaitTask* task) = 0;
97 protected:
GetWaitTaskPointer(QueueableTask * p)98     static QueueableWaitTask* GetWaitTaskPointer(QueueableTask* p) { return static_cast<QueueableWaitTask*>(p); }
99 };
100 
101 }}
102 
103 #endif
104 
105 #endif // NN_OS_OS_THREADPOOL_H_
106