13#ifndef ML_CLASSIC_HOST_H
14#define ML_CLASSIC_HOST_H
33class ProcessAllPagesHandler;
157 const std::vector <MLint>
pageIDs,
177 friend struct CalcPagesWorkerThreadFunction;
The strong handle of a MLMemoryBlock.
Classic ML host used internally to calculate getTile and processAllPages requests.
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.
MLErrorCode _processPagesHelper(PagedImage &outputImage, const SubImageBox &location, MLDataType dataType, void *data, const ScaleShiftData &scaleShiftData, bool calledByProcessAllPages)
Helper function doing the real page processing work for processAllPages or getTile methods.
std::vector< ThreadDataClass ** > _workerThreadClassData
The offset into the current ThreadDataClass array, sorted by worker threads.
static void _calcPagesMT(ThreadDataClass **threadDataContainers, ProcessingTimeLine::TimeLine *timeLine)
Calculates a sequence of output pages where each one has a set of input pages.
bool _useTimeLineProfiling
bool _shutdownWorkerThreadsFlag
Flag that signals that the worker threads should shutdown.
size_t _maxNumPagesToCalculateInSingleWorkerThread
The maximum number of pages that a single worker thread will calculate.
MLErrorCode getTile(PagedImage &outputImage, SubImageBox location, MLDataType dataType, void **data, const ScaleShiftData &scaleShiftData=ScaleShiftData())
Requests the image region location from the image outputImage.
ProcessingTimeLine & getProcessingTimeLine()
Get access to the processing time line.
void shutdownWorkerThreads()
Shuts down and frees all worker threads (all threads are joined when this method returns).
std::vector< Thread * > _workerThreads
The worker threads that are currently started.
MLint32 _errorCounter
Counter for errors detected in calcPagesMT, usually in different threads. Only valid during thread ca...
std::vector< ProcessingTimeLine::TimeLine * > _workerThreadTimeLines
Mutex _workAvailableMutex
Mutex that protects the work assignment to the worker threads.
MLErrorCode processAllPages(Module &module, MLint outputIndex, SubImageBox region, ProcessAllPagesHandler *handler)
Internal implementation of processAllPages functionality.
void _initializePageData(ThreadDataClass &tData, bool permitInCaching)
Initializes the buffer tData with all settings which is needed to compute one output page.
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.
void enableTimeLineProfiling(bool flag)
Enable time line profiling.
Host * _host
The core host.
MLint32 _numLaunchedThreads
Counter for the number of really launched threads. Only valid during thread calculations.
ThreadDataClass ** _getWorkForWorkerThread(size_t workIndex)
Returns the work for worker thread with workIndex.
MLint32 _numFinishedThreads
Counter for the number of already finished threads. Only valid during thread calculations.
ProcessingTimeLine _profile
ProcessingTimeLine::TimeLine * _guiTimeLine
void _increaseErrorCounter()
Increases the error counter (threadsafe).
MLErrorCode _getTileCore(PagedImage &outputImage, SubImageBox location, MLDataType dataType, void *data, const ScaleShiftData &scaleShiftData)
Core of the getTile method: It fills a chunk of memory assuming that it has the correct size.
Mutex _countSyncMutex
A mutex used at many position for safe manipulations of members in the host instance by threads.
The Host is the central image processing class in the ML.
Base class for an image processing module of the ML.
Class which represents an image, which manages properties of an image and image data which is located...
Base class for handlers that are used for the Module::processAllPages facility.
Timeline for a single thread.
Stores a processing time line for multiple threads.
WaitCondition implements a wait condition for thread synchronization.
#define ML_DISALLOW_COPY_AND_ASSIGN(className)
Defines basic macros.
MLint32 MLDataType
MLDataType.
MLint32 MLErrorCode
Type of an ML Error code.
boost::mutex Mutex
Defines a non-recursive mutex.
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...