16 if(m_thread->joinable()) m_thread->join();
24 if(isInterruptable()||isRunning())
return;
31 if(m_thread->joinable()) m_thread->join();
39 setInterruptable(flag);
53 std::unique_lock<std::mutex> lock(m_runningMutex);
54 m_runningCondition.wait(lock, [&]{
return !isRunning();} );
60 m_pauseBarrier->reset(2);
65 m_pauseBarrier->reset(1);
70 return (m_pauseBarrier->getBlockedCount()>0);
75 std::this_thread::sleep_for(std::chrono::seconds(seconds));
80 std::this_thread::sleep_for(std::chrono::milliseconds(millis));
85 std::this_thread::sleep_for(std::chrono::microseconds(micros));
90 return std::thread::hardware_concurrency();
95 return std::this_thread::get_id();
100 std::this_thread::yield();
109 m_pauseBarrier->block();
114 m_interrupt.store(flag, std::memory_order_relaxed);
121 if(!isInterruptable())
130 m_runningCondition.notify_all();
static void sleepInMilliSeconds(ossim_uint64 millis)
Utility method to allow one to sleep in milliseconds.
void setInterruptable(bool flag)
virtual void waitForCompletion()
Convenience to allow one to wait for this thread to finish it's work.
virtual void runInternal()
runInternal sets up internal flags such as setting m_running to true and checks to make sure it's not...
This code was derived from https://gist.github.com/mshockwave.
virtual void interrupt()
This is the interrupt interface and will cause an internal exception that is caught by...
void start()
Will actually start the thread and will call the.
This is an Interrupt exception that is thrown if the.
static void sleepInMicroSeconds(ossim_uint64 micros)
Utility method to allow one to sleep in microseconds.
virtual ~Thread()
Destructor for this thread.
Barrier is a class used to block threads so we can synchronize and entry point.
unsigned long long ossim_uint64
static ossim_uint64 getNumberOfProcessors()
Utility to return the number of processors (concurrent threads)
void resume()
This will resume a blocked thread.
virtual void setCancel(bool flag)
static void yieldCurrentThread()
Will yield the current thread.
static void sleepInSeconds(ossim_uint64 seconds)
Utility method to allow one to sleep in seconds.
Thread()
Constructor for this thread.
static std::thread::id getCurrentThreadId()
Utility method to get the current thread ID.
void pause()
Enables the thread to be paused.