Debian Codegraph @

Source/Scheduler/CTaskProcessorSchedulerThread.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_SCHEDULER_CTASKPROCESSORSCHEDULERTHREAD_H
22 #define KONCLUDE_SCHEDULER_CTASKPROCESSORSCHEDULERTHREAD_H
23
24 // Libraries includes
25 #include <QMutex>
26
27 // Namespace includes
28 #include "SchedulerSettings.h"
29 #include "CTaskProcessorThreadBase.h"
30 #include "CTaskEventHandlerBasedScheduler.h"
31 #include "CTaskHandleContext.h"
32 #include "CTaskHandleMemoryAllocationManager.h"
33 #include "CTaskHandleMemoryPoolAllocationManager.h"
34 #include "CTaskHandleLimitedReserveMemoryPoolAllocationManager.h"
35 #include "CTaskHandleAlgorithm.h"
36 #include "CTaskProcessorContextBase.h"
37 #include "CTaskDistributionCompletorCommunicator.h"
38 #include "CConcreteTaskScheduleItem.h"
39 #include "CEventDistributionMemoryPoolReleaser.h"
40 #include "CTaskReserveArrayQueue.h"
41 #include "CTaskReserveMultiArrayQueueAdderController.h"
42
43 // Other includes
44 #include "Utilities/Memory/CNewAllocationMemoryPoolProvider.h"
45 #include "Utilities/Memory/CMemoryPoolProvider.h"
46
47 #include "Scheduler/Events/CTaskDispenseNotificationEvent.h"
48
49 // Logger includes
50 #include "Logger/CLogger.h"
51
52
53
54 namespace Konclude {
55
56 using namespace Utilities::Memory;
57
58 namespace Scheduler {
59
60 using namespace Events;
61
62
63 /*!
64 *
65 * \class CTaskProcessorSchedulerThread
66 * \author Andreas Steigmiller
67 * \version 0.1
68 * \brief TODO
69 *
70 */
71 class CTaskProcessorSchedulerThread : public CTaskProcessorThreadBase, public CTaskEventHandlerBasedScheduler {
72 // public methods
73 public:
74 //! Constructor
75 CTaskProcessorSchedulerThread(CTaskHandleAlgorithm* taskHandleAlgo, CTaskEventHandlerBasedDistributionCompletor* distributorCompletor, CConsiderateMemoryPoolProvider* memoryPoolProvider = nullptr);
76
77 //! Destructor
78 virtual ~CTaskProcessorSchedulerThread();
79
80 virtual CTaskReserveQueueConsumer* createTaskReserveQueueConsumer(CTaskEventHandlerBasedProcessor* taskProcessor);
81
82 virtual CTaskSchedulerCommunicator* createSchedulerProcessorCommunication(CTaskEventHandlerBasedProcessor* taskProcessor);
83 virtual CTaskEventHandlerBasedProcessor* installScheduler(CTaskEventHandlerBasedScheduler* scheduler);
84
85 virtual bool requiresTaskDispenseNotification(cint64 &updateDispenseNotificationTag);
86
87 CTaskReserveQueue* getTaskReserveQueue();
88 CTaskReserveQueueAdder* createTaskReserveQueueAdder();
89
90 // protected methods
91 protected:
92 virtual CTaskProcessorSchedulerThread* installSchedulerCommunicator(CTaskSchedulerCommunicator* schedulerCommunicator);
93
94 virtual bool processEvent(CEvent *event, CContext* handlerContext);
95
96 virtual bool processDispenseNotification();
97 virtual bool processRequestProcessTask();
98 virtual bool processCriticalScheduleTask();
99 virtual bool processCompleteTask(CTask* task);
100 virtual bool processAdditionalTaskAllocation(CTask* task, CMemoryPool* memoryPool);
101 virtual bool processResponseScheduleTask(CTask* task, CTaskScheduleItem* taskScheduleItem, bool schedulingTask);
102 virtual bool processUpdateTaskStatus(CTask* task);
103 virtual bool processUpdateTaskStatus(CTask* parentTask, CTask* updateTask);
104
105
106 virtual bool processSchedulerRequestProcessTask(CTaskSchedulerCommunicator* communicator);
107 virtual bool processSchedulerCriticalScheduleTask(CTaskSchedulerCommunicator* communicator);
108 virtual bool processSchedulerResponseScheduleTask(CTask* task, CTaskSchedulerCommunicator* communicator, CTaskScheduleItem* taskScheduleItem, bool schedulingTask);
109 virtual bool processSchedulerScheduleTask(CTask* task, bool schedulingTask);
110 virtual bool processTaskScheduling();
111 virtual bool processSchedulingScheduleTasks();
112 virtual bool processSchedulerDispenseNotification(CTaskSchedulerCommunicator* communicator);
113
114 virtual bool requiresSchedulingTasks();
115
116 // protected variables
117 protected:
118 CConsiderateMemoryPoolProvider* mMemoryPoolProvider;
119 CDistributionMemoryPoolReleaser* mMemoryPoolReleaser;
120 CTaskDistributionCompletorCommunicator* mDistributorCompletorCommunicator;
121
122 // scheduler variables
123
124 CConcreteTaskScheduleItem* mFreeSchedulerItemLinker;
125 CConcreteTaskScheduleItem* mWaitingSchedulerItemLinker;
126 CXLinker<CConcreteTaskSchedulerCommunicator*>* mSchedulerCommunicatorLinker;
127
128 cint64 mRequestingTaskCount;
129 cint64 mDeliveringWaitingCount;
130 bool mRequiresTaskDispenseNotification;
131 cint64 mSchedulerDispenseNotificationTag;
132 bool mProcessorWithCriticalScheduleTask;
133
134 QMutex mCreateCommunicatorSyncMutex;
135
136 CTaskSchedulerCommunicator* mSchedulerCommunicator;
137 CTaskReserveArrayQueue* mTaskReserveQueue;
138 CTaskReserveMultiArrayQueueAdderController* mTaskReserveQueueController;
139
140 // processor variables
141 cint64 mDispenseNotificationTag;
142
143 // for debugging only
144 CTask* mLastScheduledTask;
145
146 // private methods
147 private:
148
149 // private variables
150 private:
151
152 };
153
154 }; // end namespace Scheduler
155
156 }; // end namespace Konclude
157
158 #endif // KONCLUDE_SCHEDULER_CTASKPROCESSORSCHEDULERTHREAD_H