13 #ifndef ML_MULTI_THREADED_PAGE_REQUEST_PROCESSOR_H
14 #define ML_MULTI_THREADED_PAGE_REQUEST_PROCESSOR_H
22 #include "ThirdPartyWarningsDisable.h"
23 #include <boost/thread.hpp>
24 #include "ThirdPartyWarningsRestore.h"
29 #define ML_HOST_START_SINGLETHREADED_TIMEOUT 0.0005
31 #define ML_HOST_PAGEREQUEST_QUEUE_LIMIT 2
33 #define ML_HOST_PAGEREQUEST_PRODUCER_BATCH_SIZE 2
35 #define ML_HOST_START_SINGLETHREADED_PAGEREQUEST_LIMIT 10
37 #define ML_HOST_MINIMAL_GUITHREAD_SLEEP_MS 10
87 struct WorkerThreadState;
90 bool processNextGUIRequest(
int millisecondsToWait);
93 void processNextWorkerRequest(WorkerThreadState* state, PerThreadStorage& perThreadStorage);
99 static void rootTileRequestFinishedCB(
void* data,
TileRequest* request);
102 void rootTileRequestFinished(
TileRequest* request);
105 void runPageRequestProducerLoop();
108 void addNewCursors();
111 void runWorkerThreadLoop(WorkerThreadState* state);
114 void notifyAllThreads();
117 void launchWorkerThreads();
120 int getCurrentNumberOfPageRequestsInQueues();
123 void wakeupProducerIfWaitingForQueue();
129 void stopProcessingOnAllThreads();
132 void moveRequestsFromGUIQueuesToOtherQueues();
138 void startCreatingWorkSingleThreaded();
144 bool _producerWorking;
146 int _workerThreadsWorking;
149 int _maxPageRequestsInQueues;
152 bool _producerWaitingForQueue;
155 bool _processingAllowed;
157 bool _useMultiThreading;
158 bool _processingWasSingleThreaded;
159 bool _allowLateMultiThreadingStart;
174 std::vector<PageRequestCursor*> _newCursors;
177 std::deque<PageRequest*> _parallelWorkQueue;
178 std::deque<PageRequest*> _ioWorkQueue;
181 struct WorkerThreadState
184 ~WorkerThreadState();
187 boost::thread* _thread;
199 std::deque<PageRequest*>* _queue;
209 std::size_t _numDesiredWorkerThreads;
212 std::vector<WorkerThreadState*> _workerThreads;
215 WorkerThreadState* _ioThread;
218 boost::thread* _producerThread;
221 ProcessingTimeLine::TimeLine* _producerThreadTimeLine;
224 struct ProfilingInfo {
238 std::map<PagedImage*, ProfilingInfo> _profilingData;
241 void addThreadTimesToMLProfiling();
The Host is the central image processing class in the ML.
Timeline for a single thread.
A TileRequest either represents the input subimage that is needed by a PageRequest or if it is a root...
Class to measure precise time intervals.
WaitCondition implements a wait condition for thread synchronization.
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.