OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
ossimJobThreadQueue allows one to instantiate a thread with a shared queue. More...
#include <ossimJobThreadQueue.h>
Public Member Functions | |
ossimJobThreadQueue (std::shared_ptr< ossimJobQueue > jqueue=0) | |
constructor that allows one to instantiat the thread with a shared job queue. More... | |
virtual | ~ossimJobThreadQueue () |
destructor. More... | |
void | setJobQueue (std::shared_ptr< ossimJobQueue > jqueue) |
Sets the shared queue that this thread will be pulling jobs from. More... | |
std::shared_ptr< ossimJobQueue > | getJobQueue () |
const std::shared_ptr< ossimJobQueue > | getJobQueue () const |
std::shared_ptr< ossimJob > | currentJob () |
void | cancelCurrentJob () |
Will cancel the current job. More... | |
bool | isValidQueue () const |
virtual void | run () |
This is method is overriden from the base thread class and is the main entry point of the thread. More... | |
void | setDone (bool done) |
Sets the done flag. More... | |
bool | isDone () const |
virtual void | cancel () |
Cancels the thread. More... | |
bool | isEmpty () const |
bool | isProcessingJob () const |
bool | hasJobsToProcess () const |
![]() | |
Thread () | |
Constructor for this thread. More... | |
virtual | ~Thread () |
Destructor for this thread. More... | |
void | start () |
Will actually start the thread and will call the. More... | |
bool | isRunning () const |
bool | isInterruptable () const |
This is typically set if. More... | |
virtual void | setCancel (bool flag) |
virtual void | waitForCompletion () |
Convenience to allow one to wait for this thread to finish it's work. More... | |
void | pause () |
Enables the thread to be paused. More... | |
void | resume () |
This will resume a blocked thread. More... | |
bool | isPaused () const |
Protected Member Functions | |
void | startThreadForQueue () |
Internal method. More... | |
virtual std::shared_ptr< ossimJob > | nextJob () |
Will return the next job on the queue. More... | |
![]() | |
virtual void | interrupt () |
This is the interrupt interface and will cause an internal exception that is caught by. More... | |
virtual void | runInternal () |
runInternal sets up internal flags such as setting m_running to true and checks to make sure it's not interrupted and will then call the More... | |
Protected Attributes | |
bool | m_doneFlag |
std::mutex | m_threadMutex |
std::shared_ptr< ossimJobQueue > | m_jobQueue |
std::shared_ptr< ossimJob > | m_currentJob |
Additional Inherited Members | |
![]() | |
static void | sleepInSeconds (ossim_uint64 seconds) |
Utility method to allow one to sleep in seconds. More... | |
static void | sleepInMilliSeconds (ossim_uint64 millis) |
Utility method to allow one to sleep in milliseconds. More... | |
static void | sleepInMicroSeconds (ossim_uint64 micros) |
Utility method to allow one to sleep in microseconds. More... | |
static std::thread::id | getCurrentThreadId () |
Utility method to get the current thread ID. More... | |
static ossim_uint64 | getNumberOfProcessors () |
Utility to return the number of processors (concurrent threads) More... | |
static void | yieldCurrentThread () |
Will yield the current thread. More... | |
ossimJobThreadQueue allows one to instantiate a thread with a shared queue.
the thread will block if the queue is empty and will continue to pop jobs off the queue calling the start method on the job. Once it finishes the job it is disguarded and then the next job will be popped off the queue.
Definition at line 57 of file ossimJobThreadQueue.h.
ossimJobThreadQueue::ossimJobThreadQueue | ( | std::shared_ptr< ossimJobQueue > | jqueue = 0 | ) |
constructor that allows one to instantiat the thread with a shared job queue.
jqueue | shared job queue |
Definition at line 3 of file ossimJobThreadQueue.cpp.
References setJobQueue().
|
virtual |
destructor.
Will terminate the thread and stop current jobs
Definition at line 183 of file ossimJobThreadQueue.cpp.
References cancel().
|
virtual |
Cancels the thread.
Reimplemented from ossim::Thread.
Definition at line 140 of file ossimJobThreadQueue.cpp.
References ossim::Thread::isRunning(), m_currentJob, m_doneFlag, m_jobQueue, m_threadMutex, and ossim::Thread::yieldCurrentThread().
Referenced by ~ossimJobThreadQueue().
void ossimJobThreadQueue::cancelCurrentJob | ( | ) |
Will cancel the current job.
Definition at line 43 of file ossimJobThreadQueue.cpp.
References m_currentJob, and m_threadMutex.
std::shared_ptr< ossimJob > ossimJobThreadQueue::currentJob | ( | ) |
Definition at line 37 of file ossimJobThreadQueue.cpp.
References m_currentJob, and m_threadMutex.
std::shared_ptr< ossimJobQueue > ossimJobThreadQueue::getJobQueue | ( | ) |
Definition at line 25 of file ossimJobThreadQueue.cpp.
References m_jobQueue, and m_threadMutex.
const std::shared_ptr< ossimJobQueue > ossimJobThreadQueue::getJobQueue | ( | ) | const |
Definition at line 31 of file ossimJobThreadQueue.cpp.
References m_jobQueue, and m_threadMutex.
bool ossimJobThreadQueue::hasJobsToProcess | ( | ) | const |
Definition at line 199 of file ossimJobThreadQueue.cpp.
References m_currentJob, m_jobQueue, and m_threadMutex.
bool ossimJobThreadQueue::isDone | ( | ) | const |
Definition at line 128 of file ossimJobThreadQueue.cpp.
References m_doneFlag, and m_threadMutex.
bool ossimJobThreadQueue::isEmpty | ( | ) | const |
Definition at line 177 of file ossimJobThreadQueue.cpp.
References m_jobQueue, and m_threadMutex.
bool ossimJobThreadQueue::isProcessingJob | ( | ) | const |
Definition at line 134 of file ossimJobThreadQueue.cpp.
References m_currentJob, and m_threadMutex.
bool ossimJobThreadQueue::isValidQueue | ( | ) | const |
Definition at line 51 of file ossimJobThreadQueue.cpp.
References m_jobQueue, and m_threadMutex.
Referenced by run().
|
protectedvirtual |
Will return the next job on the queue.
Definition at line 210 of file ossimJobThreadQueue.cpp.
References m_doneFlag, m_jobQueue, and m_threadMutex.
Referenced by run().
|
virtual |
This is method is overriden from the base thread class and is the main entry point of the thread.
Implements ossim::Thread.
Definition at line 57 of file ossimJobThreadQueue.cpp.
References ossim::Thread::interrupt(), isValidQueue(), m_currentJob, m_doneFlag, m_threadMutex, nextJob(), and ossim::Thread::yieldCurrentThread().
void ossimJobThreadQueue::setDone | ( | bool | done | ) |
Sets the done flag.
done | the value to set |
Definition at line 105 of file ossimJobThreadQueue.cpp.
References m_currentJob, m_doneFlag, m_jobQueue, and m_threadMutex.
void ossimJobThreadQueue::setJobQueue | ( | std::shared_ptr< ossimJobQueue > | jqueue | ) |
Sets the shared queue that this thread will be pulling jobs from.
jqueue | the shared job queue to set |
Definition at line 8 of file ossimJobThreadQueue.cpp.
References ossim::Thread::isPaused(), ossim::Thread::isRunning(), m_jobQueue, m_threadMutex, ossim::Thread::pause(), ossim::Thread::resume(), and startThreadForQueue().
Referenced by ossimJobThreadQueue().
|
protected |
Internal method.
If setJobQueue is set on this thread it will auto start this thread.
Definition at line 188 of file ossimJobThreadQueue.cpp.
References ossim::Thread::isRunning(), m_jobQueue, and ossim::Thread::start().
Referenced by setJobQueue().
|
protected |
Definition at line 162 of file ossimJobThreadQueue.h.
Referenced by cancel(), cancelCurrentJob(), currentJob(), hasJobsToProcess(), isProcessingJob(), run(), and setDone().
|
protected |
|
protected |
Definition at line 161 of file ossimJobThreadQueue.h.
Referenced by cancel(), getJobQueue(), hasJobsToProcess(), isEmpty(), isValidQueue(), nextJob(), setDone(), setJobQueue(), and startThreadForQueue().
|
mutableprotected |
Definition at line 160 of file ossimJobThreadQueue.h.
Referenced by cancel(), cancelCurrentJob(), currentJob(), getJobQueue(), hasJobsToProcess(), isDone(), isEmpty(), isProcessingJob(), isValidQueue(), nextJob(), run(), setDone(), and setJobQueue().