OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
This is the base implementation for the job queue. More...
#include <ossimJobQueue.h>
Classes | |
class | Callback |
The callback allows one to attach and listen for certain things. More... | |
Public Member Functions | |
ossimJobQueue () | |
Default constructor. More... | |
std::shared_ptr< ossimJobQueue > | getSharedFromThis () |
This is the safe way to create a std::shared_ptr for 'this'. More... | |
std::shared_ptr< const ossimJobQueue > | getSharedFromThis () const |
This is the safe way to create a std::shared_ptr for 'this'. More... | |
virtual void | add (std::shared_ptr< ossimJob > job, bool guaranteeUniqueFlag=true) |
Will add a job to the queue and if the guaranteeUniqueFlag is set it will scan and make sure the job is not on the queue before adding. More... | |
virtual std::shared_ptr< ossimJob > | removeByName (const ossimString &name) |
Allows one to remove a job passing in it's name. More... | |
virtual std::shared_ptr< ossimJob > | removeById (const ossimString &id) |
Allows one to remove a job passing in it's id. More... | |
virtual void | remove (const std::shared_ptr< ossimJob > Job) |
Allows one to pass in a job pointer to remove. More... | |
virtual void | removeStoppedJobs () |
Will remove any stopped jobs from the queue. More... | |
virtual void | clear () |
Will clear the queue. More... | |
virtual std::shared_ptr< ossimJob > | nextJob (bool blockIfEmptyFlag=true) |
Will grab the next job on the list and will return the job or a null shared_ptr. More... | |
virtual void | releaseBlock () |
will release the block and have any blocked threads continue More... | |
bool | isEmpty () const |
ossim_uint32 | size () |
void | setCallback (std::shared_ptr< Callback > c) |
Allows one to set the callback to the list. More... | |
std::shared_ptr< Callback > | callback () |
Protected Member Functions | |
ossimJob::List::iterator | findById (const ossimString &id) |
Internal method that returns an iterator. More... | |
ossimJob::List::iterator | findByName (const ossimString &name) |
Internal method that returns an iterator. More... | |
ossimJob::List::iterator | findByPointer (const std::shared_ptr< ossimJob > job) |
Internal method that returns an iterator. More... | |
ossimJob::List::iterator | findByNameOrPointer (const std::shared_ptr< ossimJob > job) |
Internal method that returns an iterator. More... | |
bool | hasJob (std::shared_ptr< ossimJob > job) |
Internal method that determines if we have the job. More... | |
Protected Attributes | |
std::mutex | m_jobQueueMutex |
ossim::Block | m_block |
ossimJob::List | m_jobQueue |
std::shared_ptr< Callback > | m_callback |
This is the base implementation for the job queue.
It allows one to add and remove jobs and to call the nextJob and, if specified, block the call if no jobs are on the queue. we derived from std::enable_shared_from_this which allows us access to a safe shared 'this' pointer. This is used internal to our callbacks.
The job queue is thread safe and can be shared by multiple threads.
Here is a quick code example on how to create a shared queue and to attach a thread to it. In this example we do not block the calling thread for nextJob
Definition at line 84 of file ossimJobQueue.h.
ossimJobQueue::ossimJobQueue | ( | ) |
|
virtual |
Will add a job to the queue and if the guaranteeUniqueFlag is set it will scan and make sure the job is not on the queue before adding.
job | The job to add to the queue. |
guaranteeUniqueFlag | if set to true will force a find to make sure the job does not already exist |
Definition at line 9 of file ossimJobQueue.cpp.
References findByPointer(), getSharedFromThis(), m_block, m_callback, m_jobQueue, m_jobQueueMutex, and ossim::Block::set().
std::shared_ptr< ossimJobQueue::Callback > ossimJobQueue::callback | ( | ) |
Definition at line 300 of file ossimJobQueue.cpp.
References m_callback, and m_jobQueueMutex.
|
virtual |
Will clear the queue.
Definition at line 143 of file ossimJobQueue.cpp.
References getSharedFromThis(), m_callback, m_jobQueue, and m_jobQueueMutex.
|
protected |
Internal method that returns an iterator.
the | id of the job to search for |
Definition at line 216 of file ossimJobQueue.cpp.
References m_jobQueue.
Referenced by removeById().
|
protected |
Internal method that returns an iterator.
name | the name of the job to search for |
Definition at line 231 of file ossimJobQueue.cpp.
References ossimString::empty(), and m_jobQueue.
Referenced by removeByName().
|
protected |
Internal method that returns an iterator.
job | it will find by the name or by the pointer |
Definition at line 253 of file ossimJobQueue.cpp.
References m_jobQueue, and n.
|
protected |
Internal method that returns an iterator.
job | the job to search for |
Definition at line 246 of file ossimJobQueue.cpp.
References m_jobQueue.
Referenced by add().
|
inline |
This is the safe way to create a std::shared_ptr for 'this'.
Calls the derived method shared_from_this
Definition at line 133 of file ossimJobQueue.h.
Referenced by add(), clear(), remove(), removeById(), removeByName(), and removeStoppedJobs().
|
inline |
This is the safe way to create a std::shared_ptr for 'this'.
Calls the derived method shared_from_this
Definition at line 141 of file ossimJobQueue.h.
|
protected |
Internal method that determines if we have the job.
job | the job you wish to search for |
Definition at line 279 of file ossimJobQueue.cpp.
References m_jobQueue.
bool ossimJobQueue::isEmpty | ( | ) | const |
Definition at line 200 of file ossimJobQueue.cpp.
References m_jobQueue, and m_jobQueueMutex.
Will grab the next job on the list and will return the job or a null shared_ptr.
You can block the caller if the queueis empty forcing it to wait for more jobs to come onto the queue
blockIfEmptyFlag | If true it will block the calling thread until more jobs appear on the queue. If false, it will return without blocking |
Definition at line 161 of file ossimJobQueue.cpp.
References ossim::Block::block(), m_block, m_jobQueue, m_jobQueueMutex, and ossim::Block::set().
|
virtual |
will release the block and have any blocked threads continue
Definition at line 196 of file ossimJobQueue.cpp.
References m_block, and ossim::Block::release().
|
virtual |
Allows one to pass in a job pointer to remove.
job | the job you wish to remove from the list |
Definition at line 87 of file ossimJobQueue.cpp.
References getSharedFromThis(), m_callback, m_jobQueue, and m_jobQueueMutex.
|
virtual |
Allows one to remove a job passing in it's id.
id | The job id |
Definition at line 64 of file ossimJobQueue.cpp.
References findById(), getSharedFromThis(), m_block, m_callback, m_jobQueue, m_jobQueueMutex, and ossim::Block::set().
|
virtual |
Allows one to remove a job passing in it's name.
name | The job name |
Definition at line 41 of file ossimJobQueue.cpp.
References ossimString::empty(), findByName(), getSharedFromThis(), m_block, m_callback, m_jobQueue, m_jobQueueMutex, and ossim::Block::set().
|
virtual |
Will remove any stopped jobs from the queue.
Definition at line 107 of file ossimJobQueue.cpp.
References getSharedFromThis(), m_callback, m_jobQueue, and m_jobQueueMutex.
void ossimJobQueue::setCallback | ( | std::shared_ptr< Callback > | c | ) |
Allows one to set the callback to the list.
c | shared_ptr to a callback |
Definition at line 294 of file ossimJobQueue.cpp.
References m_callback, and m_jobQueueMutex.
ossim_uint32 ossimJobQueue::size | ( | ) |
Definition at line 210 of file ossimJobQueue.cpp.
References m_jobQueue, and m_jobQueueMutex.
|
protected |
Definition at line 267 of file ossimJobQueue.h.
Referenced by add(), nextJob(), releaseBlock(), removeById(), and removeByName().
|
protected |
Definition at line 269 of file ossimJobQueue.h.
Referenced by add(), callback(), clear(), remove(), removeById(), removeByName(), removeStoppedJobs(), and setCallback().
|
protected |
Definition at line 268 of file ossimJobQueue.h.
Referenced by add(), clear(), findById(), findByName(), findByNameOrPointer(), findByPointer(), hasJob(), isEmpty(), nextJob(), remove(), removeById(), removeByName(), removeStoppedJobs(), and size().
|
mutableprotected |
Definition at line 266 of file ossimJobQueue.h.
Referenced by add(), callback(), clear(), isEmpty(), nextJob(), remove(), removeById(), removeByName(), removeStoppedJobs(), setCallback(), and size().