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

Classes

class  Tty
 The Tty class is a small class to hold pts/tty information. It is essentially a struct with a parameterized constructor. More...
 

Public Member Functions

 TtyMonitor ()
 Constructor.
 
std::vector< fs::path > GetTtyDevices () const
 Returns a copy of the vector of pts/tty paths. A copy is returned to avoid holding the lock on mtx_tty_monitor for an extended period. More...
 
void UpdateTtyDevices ()
 Initializes/Updates the pts/tty device paths to monitor.
 
void TtyMonitorThread ()
 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 GetLastTtyActiveTime () const
 Returns the overall last active time of all of the monitored pts/ttys. More...
 

Public Attributes

std::thread m_tty_monitor_thread
 Holds the actual tty monitor thread.
 
std::condition_variable cv_tty_monitor_thread
 Condition variable for control/synchronization of the tty monitor threads.
 
std::atomic< bool > m_interrupt_tty_monitor
 Atomic boolean that interrupts the tty monitor thread.
 

Static Private Member Functions

static std::vector< fs::path > EnumerateTtyDevices ()
 Provides the enumerated pts/tty devices. More...
 

Private Attributes

std::mutex mtx_tty_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_tty_monitor_thread
 This provides lock control for the tty monitor worker thread itself.
 
std::vector< fs::path > m_tty_device_paths
 Holds the device paths of the monitored pts/ttys. Note that this is duplicative of information in the individual tty objects, but it allows efficient comparison of the inventory of ttys.
 
std::vector< Ttym_ttys
 std::vector holding the tty objects.
 
std::atomic< int64_t > m_last_ttys_active_time
 Atomic that holds the overall last active time across all of the monitored pts/ttys.
 
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

◆ EnumerateTtyDevices()

std::vector< fs::path > TtyMonitor::EnumerateTtyDevices ( )
staticprivate

Provides the enumerated pts/tty devices.

Returns
std::vector<fs::path> of enumerated pts/tty devices.
Here is the caller graph for this function:

◆ GetLastTtyActiveTime()

int64_t TtyMonitor::GetLastTtyActiveTime ( ) const

Returns the overall last active time of all of the monitored pts/ttys.

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

◆ GetTtyDevices()

std::vector< fs::path > TtyMonitor::GetTtyDevices ( ) const

Returns a copy of the vector of pts/tty paths. A copy is returned to avoid holding the lock on mtx_tty_monitor for an extended period.

Returns
std::vector<fs::path> of the pts/tty paths

◆ IsInitialized()

bool TtyMonitor::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
Here is the caller graph for this function:

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