7 #ifndef THREADBASECLASS_H 8 #define THREADBASECLASS_H 63 int numThreads = 1,
int checkInterval = 300);
300 std::string m_sThreadName;
307 std::atomic<int> m_iHealthCheckInterval;
313 std::atomic<int> m_iNumThreads;
319 std::atomic<ThreadState> m_WorkThreadsState;
325 std::atomic<int> m_iSleepTimeMS;
333 static const int k_iHeathCheckIntervalDefault = 30;
338 static const int k_iSleepTimeDefault = 100;
343 static const int k_iNumThreadsDefault = 10;
347 #endif // THREADBASECLASS_H virtual bool start()
work thread start function
Definition: threadbaseclass.cpp:61
void workLoop()
ThreadBaseClass work loop function.
Definition: threadbaseclass.cpp:242
virtual bool stop()
work thread stop function
Definition: threadbaseclass.cpp:110
std::time_t getAllLastHealthy(size_t *pThreadId)
Function to retrieve the oldest time any of the work threads last updated their health status as heal...
Definition: threadbaseclass.cpp:305
glass3::util::ThreadState getWorkThreadsState()
Function to get the work threads state.
Definition: threadbaseclass.cpp:369
const std::string & getThreadName()
Function to retrieve the name of the work threads.
Definition: threadbaseclass.cpp:402
void setWorkThreadsState(glass3::util::ThreadState state)
Function to set threads state.
Definition: threadbaseclass.cpp:364
The neic-glass3 project namespace containing all the classes and functions that make up neic-glass3...
std::map< std::thread::id, std::atomic< int > > m_ThreadHealthMap
A std::map containing the epoch times as std::atomic<double>> that each work thread was last marked a...
Definition: threadbaseclass.h:293
glass3::util::BaseClass class - encapsulates the most basic setup and configuration logic...
Definition: baseclass.h:30
WorkState
glass3::util::WorkState enumeration
Definition: workstate.h:25
int getHealthCheckInterval()
Function to retrieve the work threads health check interval.
Definition: threadbaseclass.cpp:354
void setThreadHealth(bool health=true)
Function to set thread health.
Definition: threadbaseclass.cpp:164
virtual glass3::util::WorkState work()=0
ThreadBaseClass work function.
ThreadState
glass3::util::ThreadState enumeration
Definition: threadstate.h:24
int getSleepTime()
Retrieves the time to sleep between work() calls.
Definition: threadbaseclass.cpp:397
void setNumThreads(int numThreads)
Sets the number of work threads.
Definition: threadbaseclass.cpp:374
void setSleepTime(int sleepTimeMS)
Sets the time to sleep between work() calls.
Definition: threadbaseclass.cpp:392
void setHealthCheckInterval(int interval)
Function to set work threads health check interval.
Definition: threadbaseclass.cpp:349
ThreadBaseClass()
ThreadBaseClass constructor.
Definition: threadbaseclass.cpp:18
~ThreadBaseClass()
ThreadBaseClass destructor.
Definition: threadbaseclass.cpp:53
std::vector< std::thread > m_WorkThreads
the std::vector that contains the work std::thread objects
Definition: threadbaseclass.h:286
virtual bool healthCheck()
work threads check function
Definition: threadbaseclass.cpp:183
bool getTerminate()
Function to retrieve whether the thread should terminate.
Definition: threadbaseclass.cpp:359
glass3::util::ThreadBaseClass class
Definition: threadbaseclass.h:34
int getNumThreads()
Retrieves the number of work threads.
Definition: threadbaseclass.cpp:387
void setLastHealthy(std::time_t now)
Function to set the last time the work thread was healthy.
Definition: threadbaseclass.cpp:407