ML Reference
|
Classic ML host used internally to calculate getTile and processAllPages requests. More...
#include <mlClassicHost.h>
Public Member Functions | |
ClassicHost (Host *host) | |
~ClassicHost () | |
MLErrorCode | processAllPages (Module &module, MLint outputIndex, SubImageBox region, ProcessAllPagesHandler *handler) ML_RETURN_VALUE_SHOULD_BE_USED |
Internal implementation of processAllPages functionality. | |
void | shutdownWorkerThreads () |
Shuts down and frees all worker threads (all threads are joined when this method returns). | |
void | enableTimeLineProfiling (bool flag) |
Enable time line profiling. | |
ProcessingTimeLine & | getProcessingTimeLine () |
Get access to the processing time line. | |
Computation of image data in different memory allocation variations | |
MLErrorCode | getTile (PagedImage &outputImage, SubImageBox location, MLDataType dataType, void **data, const ScaleShiftData &scaleShiftData=ScaleShiftData()) ML_RETURN_VALUE_SHOULD_BE_USED |
Requests the image region location from the image outputImage . | |
Protected Member Functions | |
MLErrorCode | _processPagesHelper (PagedImage &outputImage, const SubImageBox &location, MLDataType dataType, void *data, const ScaleShiftData &scaleShiftData, bool calledByProcessAllPages) ML_RETURN_VALUE_SHOULD_BE_USED |
Helper function doing the real page processing work for processAllPages or getTile methods. | |
MLErrorCode | _getTileCore (PagedImage &outputImage, SubImageBox location, MLDataType dataType, void *data, const ScaleShiftData &scaleShiftData) ML_RETURN_VALUE_SHOULD_BE_USED |
Core of the getTile method: It fills a chunk of memory assuming that it has the correct size. | |
void | _initializePageData (ThreadDataClass &tData, bool permitInCaching) |
Initializes the buffer tData with all settings which is needed to compute one output page. | |
ThreadDataClass ** | _getWorkForWorkerThread (size_t workIndex) |
Returns the work for worker thread with workIndex . | |
void | _increaseErrorCounter () |
Increases the error counter (threadsafe). | |
(Sub)Image calculation | |
void | _calcPages (PagedImage &outputImage, const std::vector< MLint > pageIDs, MLMemoryBlockHandle *memoryBlockHandles) |
For the output image outputImage , all invalid pages with numbers given by pageIDs are calculated. | |
Static Protected Member Functions | |
static void | _calcPagesMT (ThreadDataClass **threadDataContainers, ProcessingTimeLine::TimeLine *timeLine) |
Calculates a sequence of output pages where each one has a set of input pages. | |
Protected Attributes | |
Parameter | |
WaitCondition | _workAvailable |
A wait condition to signal waiting worker threads that there is more work to be done. | |
WaitCondition | _workDone |
A wait condition that signals that all threads have done their work. | |
Mutex | _workAvailableMutex |
Mutex that protects the work assignment to the worker threads. | |
std::vector< Thread * > | _workerThreads |
The worker threads that are currently started. | |
std::vector< ThreadDataClass ** > | _workerThreadClassData |
The offset into the current ThreadDataClass array, sorted by worker threads. | |
bool | _shutdownWorkerThreadsFlag |
Flag that signals that the worker threads should shutdown. | |
Mutex | _countSyncMutex |
A mutex used at many position for safe manipulations of members in the host instance by threads. | |
MLint32 | _errorCounter |
Counter for errors detected in calcPagesMT, usually in different threads. Only valid during thread calculations. | |
MLint32 | _numFinishedThreads |
Counter for the number of already finished threads. Only valid during thread calculations. | |
MLint32 | _numLaunchedThreads |
Counter for the number of really launched threads. Only valid during thread calculations. | |
size_t | _maxNumPagesToCalculateInSingleWorkerThread |
The maximum number of pages that a single worker thread will calculate. | |
Host * | _host |
The core host. | |
ProcessingTimeLine | _profile |
ProcessingTimeLine::TimeLine * | _guiTimeLine |
std::vector < ProcessingTimeLine::TimeLine * > | _workerThreadTimeLines |
bool | _useTimeLineProfiling |
Friends | |
struct | CalcPagesWorkerThreadFunction |
make the worker thread function a friend |
Classic ML host used internally to calculate getTile and processAllPages requests.
Definition at line 47 of file mlClassicHost.h.
ml::ClassicHost::ClassicHost | ( | Host * | host | ) |
ml::ClassicHost::~ClassicHost | ( | ) |
void ml::ClassicHost::_calcPages | ( | PagedImage & | outputImage, |
const std::vector< MLint > | pageIDs, | ||
MLMemoryBlockHandle * | memoryBlockHandles | ||
) | [protected] |
For the output image outputImage
, all invalid pages with numbers given by pageIDs
are calculated.
Errors throw exceptions.
Notes:
static void ml::ClassicHost::_calcPagesMT | ( | ThreadDataClass ** | threadDataContainers, |
ProcessingTimeLine::TimeLine * | timeLine | ||
) | [static, protected] |
Calculates a sequence of output pages where each one has a set of input pages.
For each page all necessary input/output/buffering information must have been initialized in initializePageData before.
MLErrorCode ml::ClassicHost::_getTileCore | ( | PagedImage & | outputImage, |
SubImageBox | location, | ||
MLDataType | dataType, | ||
void * | data, | ||
const ScaleShiftData & | scaleShiftData | ||
) | [protected] |
Core of the getTile method: It fills a chunk of memory assuming that it has the correct size.
Updating memory outputs of output images is optionally. Not to be called directly by users!
ThreadDataClass** ml::ClassicHost::_getWorkForWorkerThread | ( | size_t | workIndex | ) | [protected] |
Returns the work for worker thread with workIndex
.
void ml::ClassicHost::_increaseErrorCounter | ( | ) | [protected] |
Increases the error counter (threadsafe).
void ml::ClassicHost::_initializePageData | ( | ThreadDataClass & | tData, |
bool | permitInCaching | ||
) | [protected] |
Initializes the buffer tData
with all settings which is needed to compute one output page.
permitInCaching
must be set true only for one (the last) thread data container if many threads are calculated in parallel. Otherwise more than one thread would modify the memory output of an input.
MLErrorCode ml::ClassicHost::_processPagesHelper | ( | PagedImage & | outputImage, |
const SubImageBox & | location, | ||
MLDataType | dataType, | ||
void * | data, | ||
const ScaleShiftData & | scaleShiftData, | ||
bool | calledByProcessAllPages | ||
) | [protected] |
Helper function doing the real page processing work for processAllPages or getTile methods.
If the parameter calledByProcessedAllPages is true: Requests the image region loc from outputIndex
of the module
. The image data will be stored at memory address data as dataType
. The data will be scaled linearly dependent on the settings of the scaleShiftData
(see ScaleShiftData).
If the parameter calledByProcessedAllPages is false: Requests the image region location
from outputIndex
of the module
. Values of data
, scaleShiftData
and dataType
are ignored.
void ml::ClassicHost::enableTimeLineProfiling | ( | bool | flag | ) | [inline] |
Enable time line profiling.
Definition at line 94 of file mlClassicHost.h.
ProcessingTimeLine& ml::ClassicHost::getProcessingTimeLine | ( | ) | [inline] |
Get access to the processing time line.
Definition at line 97 of file mlClassicHost.h.
MLErrorCode ml::ClassicHost::getTile | ( | PagedImage & | outputImage, |
SubImageBox | location, | ||
MLDataType | dataType, | ||
void ** | data, | ||
const ScaleShiftData & | scaleShiftData = ScaleShiftData() |
||
) |
Requests the image region location
from the image outputImage
.
If *data
is a non NULL pointer, it must be large enough to hold the entire requested image data. If *data
is NULL, the getTile function will allocate enough memory for the image data. The image data will be stored in that memory as data type dataType
. The data will be scaled linearly dependent on the settings of the scaleShiftData (see ScaleShiftData). The return value data then pointer to the allocated memory. IMPORTANT: Memory allocated with any Host::getTile function must be freed with the Host::freeTile function or with the corresponding mapped freeTile function of the class Module.
MLErrorCode ml::ClassicHost::processAllPages | ( | Module & | module, |
MLint | outputIndex, | ||
SubImageBox | region, | ||
ProcessAllPagesHandler * | handler | ||
) |
Internal implementation of processAllPages functionality.
void ml::ClassicHost::shutdownWorkerThreads | ( | ) |
Shuts down and frees all worker threads (all threads are joined when this method returns).
friend struct CalcPagesWorkerThreadFunction [friend] |
make the worker thread function a friend
Definition at line 182 of file mlClassicHost.h.
Mutex ml::ClassicHost::_countSyncMutex [protected] |
A mutex used at many position for safe manipulations of members in the host instance by threads.
Typically for changing counters etc.
Definition at line 219 of file mlClassicHost.h.
MLint32 ml::ClassicHost::_errorCounter [protected] |
Counter for errors detected in calcPagesMT, usually in different threads. Only valid during thread calculations.
Definition at line 222 of file mlClassicHost.h.
Definition at line 237 of file mlClassicHost.h.
Host* ml::ClassicHost::_host [protected] |
The core host.
Definition at line 234 of file mlClassicHost.h.
size_t ml::ClassicHost::_maxNumPagesToCalculateInSingleWorkerThread [protected] |
The maximum number of pages that a single worker thread will calculate.
Definition at line 231 of file mlClassicHost.h.
MLint32 ml::ClassicHost::_numFinishedThreads [protected] |
Counter for the number of already finished threads. Only valid during thread calculations.
Definition at line 225 of file mlClassicHost.h.
MLint32 ml::ClassicHost::_numLaunchedThreads [protected] |
Counter for the number of really launched threads. Only valid during thread calculations.
Definition at line 228 of file mlClassicHost.h.
ProcessingTimeLine ml::ClassicHost::_profile [protected] |
Definition at line 236 of file mlClassicHost.h.
bool ml::ClassicHost::_shutdownWorkerThreadsFlag [protected] |
Flag that signals that the worker threads should shutdown.
Definition at line 215 of file mlClassicHost.h.
bool ml::ClassicHost::_useTimeLineProfiling [protected] |
Definition at line 240 of file mlClassicHost.h.
WaitCondition ml::ClassicHost::_workAvailable [protected] |
A wait condition to signal waiting worker threads that there is more work to be done.
Definition at line 200 of file mlClassicHost.h.
Mutex ml::ClassicHost::_workAvailableMutex [protected] |
Mutex that protects the work assignment to the worker threads.
Definition at line 206 of file mlClassicHost.h.
WaitCondition ml::ClassicHost::_workDone [protected] |
A wait condition that signals that all threads have done their work.
Definition at line 203 of file mlClassicHost.h.
std::vector<ThreadDataClass**> ml::ClassicHost::_workerThreadClassData [protected] |
The offset into the current ThreadDataClass array, sorted by worker threads.
Definition at line 212 of file mlClassicHost.h.
std::vector<Thread*> ml::ClassicHost::_workerThreads [protected] |
The worker threads that are currently started.
Definition at line 209 of file mlClassicHost.h.
std::vector<ProcessingTimeLine::TimeLine*> ml::ClassicHost::_workerThreadTimeLines [protected] |
Definition at line 239 of file mlClassicHost.h.