libfswatch  1.9.3
Classes | Public Member Functions | Protected Member Functions | List of all members
fsw::poll_monitor Class Reference

stat()-based monitor. More...

#include <poll_monitor.hpp>

Inheritance diagram for fsw::poll_monitor:
fsw::monitor

Classes

struct  poll_monitor_data
 

Public Member Functions

 poll_monitor (std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
 Constructs an instance of this class.
 
virtual ~poll_monitor ()
 Destroys an instance of this class.
 
- Public Member Functions inherited from fsw::monitor
 monitor (std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
 Constructs a monitor watching the specified paths. More...
 
virtual ~monitor ()
 Destructs a monitor instance. More...
 
 monitor (const monitor &orig)=delete
 This class is not copy constructible.
 
monitoroperator= (const monitor &that)=delete
 This class is not copy assignable.
 
void set_property (const std::string &name, const std::string &value)
 Sets a custom property. More...
 
void set_properties (const std::map< std::string, std::string > options)
 Sets the custom properties. More...
 
std::string get_property (std::string name)
 Gets the value of a property. More...
 
void set_latency (double latency)
 Sets the latency. More...
 
void set_fire_idle_event (bool fire_idle_event)
 Sets the fire idle event flag. More...
 
void set_allow_overflow (bool overflow)
 Notify buffer overflows as change events. More...
 
void set_recursive (bool recursive)
 Recursively scan subdirectories. More...
 
void set_directory_only (bool directory_only)
 Watch directories only. More...
 
void add_filter (const monitor_filter &filter)
 Add a path filter. More...
 
void set_filters (const std::vector< monitor_filter > &filters)
 Set the path filters. More...
 
void set_follow_symlinks (bool follow)
 Follow symlinks. More...
 
void * get_context () const
 Get the pointer to the context data. More...
 
void set_context (void *context)
 Set the context data. More...
 
void start ()
 Start the monitor. More...
 
void stop ()
 Stop the monitor. More...
 
bool is_running ()
 Check whether the monitor is running. More...
 
void add_event_type_filter (const fsw_event_type_filter &filter)
 Add an event type filter. More...
 
void set_event_type_filters (const std::vector< fsw_event_type_filter > &filters)
 Set the event type filters. More...
 
void set_watch_access (bool access)
 Monitor file access. More...
 

Protected Member Functions

void run ()
 Execute monitor loop. More...
 
- Protected Member Functions inherited from fsw::monitor
bool accept_event_type (fsw_event_flag event_type) const
 Check whether an event should be accepted. More...
 
bool accept_path (const std::string &path) const
 Check whether a path should be accepted. More...
 
bool accept_path (const char *path) const
 Check whether a path should be accepted. More...
 
void notify_events (const std::vector< event > &events) const
 Notify change events. More...
 
void notify_overflow (const std::string &path) const
 Notify an overflow event. More...
 
std::vector< fsw_event_flagfilter_flags (const event &evt) const
 Filter event types. More...
 
virtual void on_stop ()
 Execute an implementation-specific stop handler. More...
 

Additional Inherited Members

- Protected Attributes inherited from fsw::monitor
std::vector< std::string > paths
 List of paths to watch. More...
 
std::map< std::string, std::string > properties
 Map of custom properties. More...
 
FSW_EVENT_CALLBACKcallback
 Callback to which change events should be notified. More...
 
void * context = nullptr
 Pointer to context data that will be passed to the monitor::callback.
 
double latency = 1.0
 Latency of the monitor.
 
bool fire_idle_event = false
 If true, the monitor will notify an event when idle. More...
 
bool allow_overflow = false
 If true, queue overflow events will be notified to the caller, otherwise the monitor will throw a libfsw_exception.
 
bool recursive = false
 If true, directories will be scanned recursively.
 
bool follow_symlinks = false
 If true, symbolic links are followed.
 
bool directory_only = false
 Flag indicating whether only directories should be monitored.
 
bool watch_access = false
 Flag indicating whether file access should be watched.
 
bool running = false
 Flag indicating whether the monitor is in the running state.
 
bool should_stop = false
 Flag indicating whether the monitor should preemptively stop.
 
std::mutex run_mutex
 Mutex used to serialize access to the monitor state from multiple threads.
 
std::mutex notify_mutex
 Mutex used to serialize access to the notify_events() method.
 

Detailed Description

stat()-based monitor.

This monitor uses the stat() function to periodically check the observed paths and detect changes.

Member Function Documentation

void fsw::poll_monitor::run ( )
protectedvirtual

Execute monitor loop.

This function implements the monitor event watching logic. This function is called from start() and it is executed on its thread. This function should block until the monitoring loop terminates: when it returns, the monitor is marked as stopped.

This function should cooperatively check the monitor::should_stop field locking monitor::run_mutex and return if set to true.

See also
start()
stop()

Implements fsw::monitor.


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