Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Platinum / Source / Core / PltTaskManager.h
blobaa1a58d6a56a3cef58d67aea6cf62845674d4d38
1 /*****************************************************************
3 | Platinum - Task Manager
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
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.
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
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.
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
33 ****************************************************************/
35 /** @file
36 Runnable Tasks Manager
39 #ifndef _PLT_TASKMANAGER_H_
40 #define _PLT_TASKMANAGER_H_
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
47 /*----------------------------------------------------------------------
48 | forward declarations
49 +---------------------------------------------------------------------*/
50 class PLT_ThreadTask;
52 /*----------------------------------------------------------------------
53 | PLT_TaskManager class
54 +---------------------------------------------------------------------*/
55 /**
56 The PLT_TaskManager class maintains a list of runnable tasks. During shutdown, it
57 can stop all running tasks. Additionally, it can limit the number of
58 tasks that can run at any given time.
60 class PLT_TaskManager
62 public:
63 /**
64 Create a new Task Manager.
65 @param max_tasks Maximum number of concurrent tasks that the task manager
66 will allow. When the value is reached, a thread calling AddTask will block until
67 a task has finished.
69 PLT_TaskManager(NPT_Cardinal max_tasks = 0);
70 virtual ~PLT_TaskManager();
72 /**
73 Start a new new task and associates it with this task manager.
74 @param task new task
75 @param delay optional time interval to wait before launching the new task
76 @param auto_destroy a flag to indicate if the task is owned by someone else
77 and thus should not destroy itself when done.
79 virtual NPT_Result StartTask(PLT_ThreadTask* task,
80 NPT_TimeInterval* delay = NULL,
81 bool auto_destroy = true);
83 /**
84 Stop all tasks associated with this task manager.
86 NPT_Result Abort();
88 /**
89 Reset task manager after an Abort so new tasks can be queued.
91 NPT_Result Reset();
93 /**
94 Returns the max number of concurrent tasks allowed. 0 for no limit.
96 NPT_Cardinal GetMaxTasks() { return m_MaxTasks; }
98 private:
99 friend class PLT_ThreadTask;
101 // called by PLT_ThreadTask
102 NPT_Result AddTask(PLT_ThreadTask* task);
103 NPT_Result RemoveTask(PLT_ThreadTask* task);
105 private:
106 NPT_List<PLT_ThreadTask*> m_Tasks;
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;
114 typedef NPT_Reference<PLT_TaskManager> PLT_TaskManagerReference;
116 #endif /* _PLT_TASKMANAGER_H_ */