kodi
PltTaskManager.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - Task Manager
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
13 |
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_TASKMANAGER_H_
40 #define _PLT_TASKMANAGER_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 
47 /*----------------------------------------------------------------------
48 | forward declarations
49 +---------------------------------------------------------------------*/
50 class PLT_ThreadTask;
51 
52 /*----------------------------------------------------------------------
53 | PLT_TaskManager class
54 +---------------------------------------------------------------------*/
61 {
62 public:
69  PLT_TaskManager(NPT_Cardinal max_tasks = 0);
70  virtual ~PLT_TaskManager();
71 
79  virtual NPT_Result StartTask(PLT_ThreadTask* task,
80  NPT_TimeInterval* delay = NULL,
81  bool auto_destroy = true);
82 
86  NPT_Result Abort();
87 
91  NPT_Result Reset();
92 
96  NPT_Cardinal GetMaxTasks() { return m_MaxTasks; }
97 
98 private:
99  friend class PLT_ThreadTask;
100 
101  // called by PLT_ThreadTask
102  NPT_Result AddTask(PLT_ThreadTask* task);
103  NPT_Result RemoveTask(PLT_ThreadTask* task);
104 
105 private:
107  NPT_Mutex m_TasksLock;
108  NPT_Queue<int>* m_Queue;
109  NPT_Cardinal m_MaxTasks;
110  NPT_Cardinal m_RunningTasks;
111  bool m_Stopping;
112 };
113 
115 
116 #endif /* _PLT_TASKMANAGER_H_ */
virtual NPT_Result StartTask(PLT_ThreadTask *task, NPT_TimeInterval *delay=NULL, bool auto_destroy=true)
Start a new new task and associates it with this task manager.
Definition: PltTaskManager.cpp:66
PLT_TaskManager(NPT_Cardinal max_tasks=0)
Create a new Task Manager.
Definition: PltTaskManager.cpp:46
NPT_Cardinal GetMaxTasks()
Returns the max number of concurrent tasks allowed.
Definition: PltTaskManager.h:96
The PLT_TaskManager class maintains a list of runnable tasks.
Definition: PltTaskManager.h:60
Definition: NptThreads.h:76
Definition: NptTime.h:50
NPT_Result Abort()
Stop all tasks associated with this task manager.
Definition: PltTaskManager.cpp:90
The PLT_ThreadTask class is a base class for executing a given task in a worker thread.
Definition: PltThreadTask.h:56
Definition: NptList.h:54
NPT_Result Reset()
Reset task manager after an Abort so new tasks can be queued.
Definition: PltTaskManager.cpp:78