MeVisLab Toolbox Reference
mlPageRequestProcessorBase.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_PAGE_REQUEST_PROCESSOR_BASE_H
14#define ML_PAGE_REQUEST_PROCESSOR_BASE_H
15
16#include "mlInitSystemML.h"
17
20
21#include <deque>
22#include <map>
23#include <vector>
24
25
26ML_START_NAMESPACE
27
28class Host;
29class PagedImage;
30class UserThreadData;
31
32//-------------------------------------------------------------------------------------------
34//-------------------------------------------------------------------------------------------
36{
37public:
40
42 virtual bool supportsMultiThreading() = 0;
43
47 void removeCancelledRequests() override;
48
51
54
56 void enableTimeLineProfiling(bool flag);
57
60
62 int getProcessingScope() const { return _processingScope; }
63
65 void enterProcessingScope() override;
66
68 void leaveProcessingScope() override;
69
70protected:
72 bool createMoreWork(bool sleepWhenBlocked, bool* allBlocked = nullptr, MLint pageRequestLimit = 100000, MLint* resultPageRequestCount = nullptr);
73
76
79
82
85
87 virtual void getAllPageRequestQueues(std::vector< std::deque<PageRequest*>* >& queues);
88
91
94
97
100 std::vector< std::vector<PageRequestCursor*> > _cursors;
101
109
118
122 {
125 errorOccurred = false;
126 }
127
129 std::deque<PageRequest*> guiQueue;
132
135
137 std::vector<PageRequest*> pageRequestsWithErrors;
138 };
139
142
145 std::vector<ScopeStackEntry> _scopeStack;
146
149
155
157 void clear();
158
161 std::map<PagedImage*, UserThreadData*> userThreadDataMap;
162 };
163
166
169
170};
171
172ML_END_NAMESPACE
173
174#endif
175
virtual void handleErrorsInGUIThread()
Handles all errors that have been accumulated.
int _processingScope
The current processing scope (0 = BG tasks, 1 = normal get tile, >1 = recursive get tile).
ProcessingTimeLine::TimeLine * _overviewTimeLine
void removeCancelledRequests() override
TimeCounter _progressUpdateTimer
Timer used for progress update from GUI thread.
void enableTimeLineProfiling(bool flag)
Enables/disables timeline profiling.
bool createMoreWork(bool sleepWhenBlocked, bool *allBlocked=nullptr, MLint pageRequestLimit=100000, MLint *resultPageRequestCount=nullptr)
Creates more work items, returns true if new work was created.
ProcessingTimeLine::TimeLine * _guiThreadTimeLine
virtual void getAllPageRequestQueues(std::vector< std::deque< PageRequest * > * > &queues)
Returns all page request queues (to be derived when there are more than the GUI queues).
int _producerProcessingScope
The current cursor scope of the producer.
PageRequestProcessorBase(Host *host)
void terminateAllRequestsInGUIThread()
Terminates all requests.
int _guiThreadRecursionCounter
The recursion of the GUI thread (0 = outer entry).
ProcessingTimeLine & getProcessingTimeLine()
Returns access to the processing timeline.
void setupCurrentProcessingScope()
Helper.
void enterProcessingScope() override
Enters a recursive processing scope. This is always called from main thread!
UserThreadData * getUserThreadData(PageRequest *request, PerThreadStorage &perThreadStorage)
Returns or allocates the UserThreadData for the given request as part of the perThreadStorage.
int getProcessingScope() const
Returns the current processing scope.
void leaveProcessingScope() override
Leaves a recursive processing scope. This is always called from main thread!
bool isTimeLineProfilingEnabled() const
Returns whether timeline profiling is enabled.
int _rootTileRequests
The number of root tile requests; if this gets down to 0, we are done.
Host * _host
Optional pointer to the host.
std::vector< std::vector< PageRequestCursor * > > _cursors
PerThreadStorage _guiPerThreadStorage
The per-thread storage for the GUI thread.
bool _terminated
Flag whether the calculation was terminated.
ProcessingTimeLine::TimeLine * getOverviewTimeLine()
Returns access to the overview timeline (only if timeline profiling is on).
void addNewCursor(PageRequestCursor *cursor)
Adds the new cursor.
int _producerCursorCounter
How many cursors the producer contains in all lists.
std::vector< ScopeStackEntry > _scopeStack
virtual bool supportsMultiThreading()=0
Returns whether multithreading is supported.
ScopeStackEntry * _currentScope
The current scope pointer.
Abstract base class for page request processors.
Timeline for a single thread.
Stores a processing timeline for multiple threads.
Class to measure precise time intervals.
Base class for thread local data that is passed to CalculateOutputImageHandler::calculateOutputSubIma...
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
MLint64 MLint
Definition mlTypeDefs.h:489
std::map< PagedImage *, UserThreadData * > userThreadDataMap
void clear()
Clears (and deletes) the cached data.
bool errorOccurred
Flag that indicates that an error occurred and that it needs to be handled in the GUI thread.
std::deque< PageRequest * > guiQueue
The GUI work queue.
int rootTilesToWaitFor
How many pending root tiles on this scope?
std::vector< PageRequest * > pageRequestsWithErrors
The list of page requests that have an error and need to be handled.