The Monitor class provides the framework for monitoring event activity recorded by the EventRecorders class EventRecorder threads. It also monitors changes in the input event devices and resets the EventRecorder threads if they change. It also updates the m_last_active_time. The class is a singleton and has one instantiated thread. It uses locks to protect the event_monitor device paths and the thread. The m_last_active_time is an atomic and requires no explicit locking.
More...
#include <event_detect.h>
|
|
| Monitor () |
| | Constructor.
|
| |
| std::vector< fs::path > | GetEventDevices () const |
| | Provides a copy of the m_event_device_paths private member. The copy is provided instead of a reference to minimize the lock time held on mtx_event_monitor. More...
|
| |
|
void | UpdateEventDevices () |
| | This calls the private method EnumerateEventDevices() and updates the m_event_device_paths private member.
|
| |
|
void | EventActivityMonitorThread () |
| | This is the function that is the entry point for the event activity monitor worker 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 | GetLastActiveTime () const |
| | Provides the last active time on this machine globally based on the activated monitors/recorders. More...
|
| |
|
|
std::thread | m_monitor_thread |
| | Holds the actual monitor thread.
|
| |
|
std::condition_variable | cv_monitor_thread |
| | Condition variable for control/synchronization of the monitor thread.
|
| |
|
std::atomic< bool > | m_interrupt_monitor |
| | Atomic boolean that interrupts the monitor thread.
|
| |
|
| void | WriteLastActiveTimeToFile (const fs::path &filepath) |
| | This is the whole point of the application. This writes out the last active time determined by the monitor. More...
|
| |
|
| static std::vector< fs::path > | EnumerateEventDevices () |
| | This is a private method to determine the input event devices to monitor. In particular we only want to monitor pointing devices (mice). More...
|
| |
|
|
std::mutex | mtx_event_monitor |
| | This is the mutex member that provides lock control for the event monitor object. This is used to ensure the event monitor is thread-safe.
|
| |
|
std::mutex | mtx_event_monitor_thread |
| | This provides lock control for the monitor worker thread itself.
|
| |
|
std::vector< fs::path > | m_event_device_paths |
| | Holds the paths of the input event devices to monitor.
|
| |
|
std::atomic< int64_t > | m_last_active_time |
| | holds the last active time determined by the monitor. This is an atomic, which means it can be written to/read from without holding the mtx_event_monitor lock.
|
| |
|
std::atomic< bool > | m_initialized |
| | This holds the flag as to whether the monitor has been initialized and is provided by the IsInitialized() public method.
|
| |
The Monitor class provides the framework for monitoring event activity recorded by the EventRecorders class EventRecorder threads. It also monitors changes in the input event devices and resets the EventRecorder threads if they change. It also updates the m_last_active_time. The class is a singleton and has one instantiated thread. It uses locks to protect the event_monitor device paths and the thread. The m_last_active_time is an atomic and requires no explicit locking.
◆ EnumerateEventDevices()
| std::vector< fs::path > Monitor::EnumerateEventDevices |
( |
| ) |
|
|
staticprivate |
This is a private method to determine the input event devices to monitor. In particular we only want to monitor pointing devices (mice).
- Returns
◆ GetEventDevices()
| std::vector< fs::path > Monitor::GetEventDevices |
( |
| ) |
const |
Provides a copy of the m_event_device_paths private member. The copy is provided instead of a reference to minimize the lock time held on mtx_event_monitor.
- Returns
- std::vector<fs::path> of the input event device paths.
◆ GetLastActiveTime()
| int64_t Monitor::GetLastActiveTime |
( |
| ) |
const |
Provides the last active time on this machine globally based on the activated monitors/recorders.
- Returns
◆ IsInitialized()
| bool Monitor::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
◆ WriteLastActiveTimeToFile()
| void Monitor::WriteLastActiveTimeToFile |
( |
const fs::path & |
filepath | ) |
|
|
private |
This is the whole point of the application. This writes out the last active time determined by the monitor.
- Parameters
-
The documentation for this class was generated from the following files: