ML 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
18
#include "
mlPageRequestProcessor.h
"
19
#include "
mlProcessingTimeLine.h
"
20
21
#include <deque>
22
#include <map>
23
#include <vector>
24
25
26
ML_START_NAMESPACE
27
28
class
Host;
29
class
PagedImage;
30
class
UserThreadData;
31
32
//-------------------------------------------------------------------------------------------
34
//-------------------------------------------------------------------------------------------
35
class
MLEXPORT
PageRequestProcessorBase
:
public
PageRequestProcessor
36
{
37
public
:
38
PageRequestProcessorBase
(
Host
* host);
39
~PageRequestProcessorBase
()
override
;
40
42
virtual
bool
supportsMultiThreading
() = 0;
43
47
void
removeCancelledRequests
()
override
;
48
50
ProcessingTimeLine
&
getProcessingTimeLine
() {
return
_profile; }
51
53
ProcessingTimeLine::TimeLine
*
getOverviewTimeLine
() {
return
_useTimeLineProfiling?_overviewTimeLine:
nullptr
; }
54
56
void
enableTimeLineProfiling
(
bool
flag);
57
59
bool
isTimeLineProfilingEnabled
()
const
{
return
_useTimeLineProfiling; }
60
62
int
getProcessingScope
()
const
{
return
_processingScope; }
63
65
void
enterProcessingScope
()
override
;
66
68
void
leaveProcessingScope
()
override
;
69
70
protected
:
72
bool
createMoreWork
(
bool
sleepWhenBlocked,
bool
* allBlocked =
nullptr
,
MLint
pageRequestLimit = 100000,
MLint
* resultPageRequestCount =
nullptr
);
73
75
void
setupCurrentProcessingScope
();
76
78
virtual
void
handleErrorsInGUIThread
();
79
81
void
terminateAllRequestsInGUIThread
();
82
84
void
addNewCursor
(
PageRequestCursor
* cursor);
85
87
virtual
void
getAllPageRequestQueues
(std::vector< std::deque<PageRequest*>* >& queues);
88
90
Host
*
_host
;
91
93
bool
_terminated
;
94
96
int
_rootTileRequests
;
97
100
std::vector< std::vector<PageRequestCursor*> >
_cursors
;
101
104
bool
_useTimeLineProfiling
;
105
ProcessingTimeLine
_profile
;
106
ProcessingTimeLine::TimeLine
*
_guiThreadTimeLine
;
107
ProcessingTimeLine::TimeLine
*
_overviewTimeLine
;
109
111
int
_processingScope
;
113
int
_producerProcessingScope
;
115
int
_producerCursorCounter
;
117
int
_guiThreadRecursionCounter
;
118
121
struct
ScopeStackEntry
122
{
123
ScopeStackEntry
() {
124
rootTilesToWaitFor = 0;
125
errorOccurred =
false
;
126
}
127
129
std::deque<PageRequest*>
guiQueue
;
131
int
rootTilesToWaitFor
;
132
134
bool
errorOccurred
;
135
137
std::vector<PageRequest*>
pageRequestsWithErrors
;
138
};
139
141
ScopeStackEntry
*
_currentScope
;
142
145
std::vector<ScopeStackEntry>
_scopeStack
;
146
148
TimeCounter
_progressUpdateTimer
;
149
153
struct
PerThreadStorage
{
154
~PerThreadStorage
() { clear(); }
155
157
void
clear
();
158
161
std::map<PagedImage*, UserThreadData*>
userThreadDataMap
;
162
};
163
165
PerThreadStorage
_guiPerThreadStorage
;
166
168
UserThreadData
*
getUserThreadData
(
PageRequest
* request,
PerThreadStorage
& perThreadStorage);
169
170
};
171
172
ML_END_NAMESPACE
173
174
#endif
175
ml::Host
The Host is the central image processing class in the ML.
Definition
mlHost.h:115
ml::PageRequestCursor
A cursor to create page and tile requests in an iterative manner, to allow breaking/resuming at any t...
Definition
mlPageRequestCursor.h:39
ml::PageRequestProcessorBase
Base class for single and multi-threaded processor.
Definition
mlPageRequestProcessorBase.h:36
ml::PageRequestProcessorBase::handleErrorsInGUIThread
virtual void handleErrorsInGUIThread()
handle all errors that have been accumulated
ml::PageRequestProcessorBase::_processingScope
int _processingScope
the current processing scope (0 = BG tasks, 1 = normal get tile, >1 = recursive get tile
Definition
mlPageRequestProcessorBase.h:111
ml::PageRequestProcessorBase::_overviewTimeLine
ProcessingTimeLine::TimeLine * _overviewTimeLine
Definition
mlPageRequestProcessorBase.h:107
ml::PageRequestProcessorBase::removeCancelledRequests
void removeCancelledRequests() override
Removes all requests that are canceled and no longer needed.
ml::PageRequestProcessorBase::_progressUpdateTimer
TimeCounter _progressUpdateTimer
Timer used for progress update from GUI thread.
Definition
mlPageRequestProcessorBase.h:148
ml::PageRequestProcessorBase::enableTimeLineProfiling
void enableTimeLineProfiling(bool flag)
Enable/disable time line profiling.
ml::PageRequestProcessorBase::createMoreWork
bool createMoreWork(bool sleepWhenBlocked, bool *allBlocked=nullptr, MLint pageRequestLimit=100000, MLint *resultPageRequestCount=nullptr)
Creates more work items, returns true if new work was created.
ml::PageRequestProcessorBase::_guiThreadTimeLine
ProcessingTimeLine::TimeLine * _guiThreadTimeLine
Definition
mlPageRequestProcessorBase.h:106
ml::PageRequestProcessorBase::getAllPageRequestQueues
virtual void getAllPageRequestQueues(std::vector< std::deque< PageRequest * > * > &queues)
get all page request queues (to be derived when there are more than the GUI queues)
ml::PageRequestProcessorBase::_producerProcessingScope
int _producerProcessingScope
the current cursor scope of the producer
Definition
mlPageRequestProcessorBase.h:113
ml::PageRequestProcessorBase::PageRequestProcessorBase
PageRequestProcessorBase(Host *host)
ml::PageRequestProcessorBase::terminateAllRequestsInGUIThread
void terminateAllRequestsInGUIThread()
terminate all requests
ml::PageRequestProcessorBase::_guiThreadRecursionCounter
int _guiThreadRecursionCounter
the recursion of the GUI thread (0 = outer entry)
Definition
mlPageRequestProcessorBase.h:117
ml::PageRequestProcessorBase::getProcessingTimeLine
ProcessingTimeLine & getProcessingTimeLine()
Get access to the processing time line.
Definition
mlPageRequestProcessorBase.h:50
ml::PageRequestProcessorBase::setupCurrentProcessingScope
void setupCurrentProcessingScope()
helper
ml::PageRequestProcessorBase::_useTimeLineProfiling
bool _useTimeLineProfiling
Definition
mlPageRequestProcessorBase.h:104
ml::PageRequestProcessorBase::enterProcessingScope
void enterProcessingScope() override
Enters a recursive processing scope (always called from main thread!)
ml::PageRequestProcessorBase::getUserThreadData
UserThreadData * getUserThreadData(PageRequest *request, PerThreadStorage &perThreadStorage)
Gets or allocates the UserThreadData for the given request as part of the perThreadStorage.
ml::PageRequestProcessorBase::~PageRequestProcessorBase
~PageRequestProcessorBase() override
ml::PageRequestProcessorBase::getProcessingScope
int getProcessingScope() const
Return the current processing scope.
Definition
mlPageRequestProcessorBase.h:62
ml::PageRequestProcessorBase::leaveProcessingScope
void leaveProcessingScope() override
Leaves a recursive processing scope (always called from main thread!)
ml::PageRequestProcessorBase::isTimeLineProfilingEnabled
bool isTimeLineProfilingEnabled() const
Returns if time line profiling is enabled.
Definition
mlPageRequestProcessorBase.h:59
ml::PageRequestProcessorBase::_rootTileRequests
int _rootTileRequests
the number of root tile requests, if this gets down to 0, we are done
Definition
mlPageRequestProcessorBase.h:96
ml::PageRequestProcessorBase::_host
Host * _host
optional pointer to the host
Definition
mlPageRequestProcessorBase.h:90
ml::PageRequestProcessorBase::_cursors
std::vector< std::vector< PageRequestCursor * > > _cursors
The cursors that are handled by the producer thread, one list for each processing scope.
Definition
mlPageRequestProcessorBase.h:100
ml::PageRequestProcessorBase::_guiPerThreadStorage
PerThreadStorage _guiPerThreadStorage
The per thread storage for the GUI thread.
Definition
mlPageRequestProcessorBase.h:165
ml::PageRequestProcessorBase::_terminated
bool _terminated
flag if the calculation was terminated
Definition
mlPageRequestProcessorBase.h:93
ml::PageRequestProcessorBase::getOverviewTimeLine
ProcessingTimeLine::TimeLine * getOverviewTimeLine()
Get access to the overview time line (only if time line profiling is on)
Definition
mlPageRequestProcessorBase.h:53
ml::PageRequestProcessorBase::addNewCursor
void addNewCursor(PageRequestCursor *cursor)
add the new cursor
ml::PageRequestProcessorBase::_profile
ProcessingTimeLine _profile
Definition
mlPageRequestProcessorBase.h:105
ml::PageRequestProcessorBase::_producerCursorCounter
int _producerCursorCounter
how many cursors the producer contains in all lists
Definition
mlPageRequestProcessorBase.h:115
ml::PageRequestProcessorBase::_scopeStack
std::vector< ScopeStackEntry > _scopeStack
Stack of processing scopes for performance reasons, we only grow this stack, we never shrink it.
Definition
mlPageRequestProcessorBase.h:145
ml::PageRequestProcessorBase::supportsMultiThreading
virtual bool supportsMultiThreading()=0
Returns if multi-threading is supported.
ml::PageRequestProcessorBase::_currentScope
ScopeStackEntry * _currentScope
the current scope pointer
Definition
mlPageRequestProcessorBase.h:141
ml::PageRequestProcessor
Abstract base class for page request processors.
Definition
mlPageRequestProcessor.h:47
ml::PageRequest
A PageRequest represents the request for the calculation of a single page of a PagedImage.
Definition
mlPageRequest.h:32
ml::ProcessingTimeLine::TimeLine
Timeline for a single thread.
Definition
mlProcessingTimeLine.h:40
ml::ProcessingTimeLine
Stores a processing time line for multiple threads.
Definition
mlProcessingTimeLine.h:30
ml::TimeCounter
Class to measure precise time intervals.
Definition
mlTimeCounter.h:26
ml::UserThreadData
Base class for thread local data that is passed to CalculateOutputImageHandler::calculateOutputSubIma...
Definition
mlModuleInterfaces.h:31
mlInitSystemML.h
MLEXPORT
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
Definition
mlInitSystemML.h:38
mlPageRequestProcessor.h
mlProcessingTimeLine.h
MLint
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition
mlTypeDefs.h:490
ml::PageRequestProcessorBase::PerThreadStorage
Data this is available on a per-thread basis to cache things that are reused across PageRequest calls...
Definition
mlPageRequestProcessorBase.h:153
ml::PageRequestProcessorBase::PerThreadStorage::userThreadDataMap
std::map< PagedImage *, UserThreadData * > userThreadDataMap
A map of UserThreadData for each PagedImage, UserThreadData objects are owned by the map.
Definition
mlPageRequestProcessorBase.h:161
ml::PageRequestProcessorBase::PerThreadStorage::~PerThreadStorage
~PerThreadStorage()
Definition
mlPageRequestProcessorBase.h:154
ml::PageRequestProcessorBase::PerThreadStorage::clear
void clear()
clears (and deletes) the cached data
ml::PageRequestProcessorBase::ScopeStackEntry
Each processing scope has its own GUI work queue and flags/counters for errors and tiles to wait for.
Definition
mlPageRequestProcessorBase.h:122
ml::PageRequestProcessorBase::ScopeStackEntry::errorOccurred
bool errorOccurred
flag that indicates that an error occurred and that it needs to be handled in the GUI thread
Definition
mlPageRequestProcessorBase.h:134
ml::PageRequestProcessorBase::ScopeStackEntry::guiQueue
std::deque< PageRequest * > guiQueue
the GUI work queue
Definition
mlPageRequestProcessorBase.h:129
ml::PageRequestProcessorBase::ScopeStackEntry::ScopeStackEntry
ScopeStackEntry()
Definition
mlPageRequestProcessorBase.h:123
ml::PageRequestProcessorBase::ScopeStackEntry::rootTilesToWaitFor
int rootTilesToWaitFor
how many pending root tiles on this scope?
Definition
mlPageRequestProcessorBase.h:131
ml::PageRequestProcessorBase::ScopeStackEntry::pageRequestsWithErrors
std::vector< PageRequest * > pageRequestsWithErrors
the list of page requests that have an error and need to be handled
Definition
mlPageRequestProcessorBase.h:137
MeVis
Foundation
Sources
ML
include
host
mlPageRequestProcessorBase.h
Generated by
1.10.0