idle_detect  0.8.3.0
Provides overall idle detection for a linux computer
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
EventDetect::IdleDetectMonitor Class Reference

Public Types

enum  State { UNKNOWN, NORMAL, FORCED_ACTIVE, FORCED_IDLE }
 

Public Member Functions

 IdleDetectMonitor ()
 Constructor.
 
void IdleDetectMonitorThread ()
 Method to instantiate the tty monitor thread.
 
bool IsInitialized () const
 Provides a flag to indicate whether the monitor has been initialized. This is used in main in the application control paths. More...
 
int64_t GetLastIdleDetectActiveTime () const
 Returns the overall last active time of all of the message receipts from idle_detect instances. More...
 
State GetState () const
 Returns the state of the idle monitor. This is NORMAL, FORCED_ACTIVE or FORCED_IDLE. More...
 
std::string StateToString () const
 Returns the string representation of the idle monitor object state. More...
 

Static Public Member Functions

static std::string StateToString (const State &state)
 Returns the string representation of the input state enum value. More...
 

Public Attributes

std::thread m_idle_detect_monitor_thread
 Holds the actual idle_detect monitor thread.
 
std::condition_variable cv_idle_detect_monitor_thread
 Condition variable for control/synchronization of the idle_detect monitor threads.
 
std::atomic< bool > m_interrupt_idle_detect_monitor
 Atomic boolean that interrupts the idle_detect monitor thread.
 

Private Attributes

std::mutex mtx_idle_detect_monitor
 This is the mutex member that provides lock control for the tty monitor object. This is used to ensure the tty monitor is thread-safe.
 
std::mutex mtx_idle_detect_monitor_thread
 This provides lock control for the tty monitor worker thread itself.
 
std::atomic< int64_t > m_last_idle_detect_active_time
 Atomic that holds the overall last active time across all of the monitored pts/ttys.
 
std::atomic< State > m_state
 Holds the current state of the idle monitor. NORMAL means idle detect follows the normal threshold (trigger) rules for idle detection. FORCED_ACTIVE means the user has forced the system to be active and FORCED_IDLE means the user has forced the system to be idle. The state is set by the event_detect process and is used to determine the ultimate last active time.
 
std::atomic< bool > m_initialized
 This holds the flag as to whether the tty monitor has been initialized and is provided by the IsInitialized() public method.
 

Member Function Documentation

◆ GetLastIdleDetectActiveTime()

int64_t IdleDetectMonitor::GetLastIdleDetectActiveTime ( ) const

Returns the overall last active time of all of the message receipts from idle_detect instances.

Returns
Unix Epoch time in seconds
Here is the caller graph for this function:

◆ GetState()

IdleDetectMonitor::State IdleDetectMonitor::GetState ( ) const

Returns the state of the idle monitor. This is NORMAL, FORCED_ACTIVE or FORCED_IDLE.

Returns
State enum value
Here is the caller graph for this function:

◆ IsInitialized()

bool IdleDetectMonitor::IsInitialized ( ) const

Provides a flag to indicate whether the monitor has been initialized. This is used in main in the application control paths.

Returns
boolean flag

◆ StateToString() [1/2]

std::string IdleDetectMonitor::StateToString ( const State &  state)
static

Returns the string representation of the input state enum value.

Parameters
Stateenum state
Returns
string representation of the state
Here is the caller graph for this function:

◆ StateToString() [2/2]

std::string IdleDetectMonitor::StateToString ( ) const

Returns the string representation of the idle monitor object state.

Returns
string represenation of the state
Here is the caller graph for this function:

The documentation for this class was generated from the following files: