fswatch  1.14.0
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
fsw::fsevents_monitor Class Reference

OS X FSEvents monitor. More...

#include <fsevents_monitor.hpp>

Inheritance diagram for fsw::fsevents_monitor:
fsw::monitor

Public Member Functions

 fsevents_monitor (std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
 Constructs an instance of this class.
 
 fsevents_monitor (const fsevents_monitor &orig)=delete
 
fsevents_monitoroperator= (const fsevents_monitor &that)=delete
 
- 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...
 

Static Public Attributes

static constexpr const char * DARWIN_EVENTSTREAM_NO_DEFER = "darwin.eventStream.noDefer"
 Custom monitor property used to enable the kFSEventStreamCreateFlagNoDefer flag in the event stream. More...
 

Protected Member Functions

void run () override
 Executes the monitor loop. More...
 
void on_stop () override
 Execute an implementation-specific stop handler.
 
- 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...
 
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...
 

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

OS X FSEvents monitor.

This monitor is built upon the FSEvents API of the Apple OS X kernel.

Member Function Documentation

◆ run()

void fsw::fsevents_monitor::run ( )
overrideprotectedvirtual

Executes the monitor loop.

This call does not return until the monitor is stopped.

See also
stop()

Implements fsw::monitor.

Member Data Documentation

◆ DARWIN_EVENTSTREAM_NO_DEFER

constexpr const char* fsw::fsevents_monitor::DARWIN_EVENTSTREAM_NO_DEFER = "darwin.eventStream.noDefer"
static

Custom monitor property used to enable the kFSEventStreamCreateFlagNoDefer flag in the event stream.

If you specify this flag and more than latency seconds have elapsed since the last event, your app will receive the event immediately. The delivery of the event resets the latency timer and any further events will be delivered after latency seconds have elapsed. This flag is useful for apps that are interactive and want to react immediately to changes but avoid getting swamped by notifications when changes are occurring in rapid succession. If you do not specify this flag, then when an event occurs after a period of no events, the latency timer is started. Any events that occur during the next latency seconds will be delivered as one group (including that first event). The delivery of the group of events resets the latency timer and any further events will be delivered after latency seconds. This is the default behavior and is more appropriate for background, daemon or batch processing apps.

See also
https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagnodefer

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