Qore fsevent Module ..
|
Delayed file notification handler. More...
#include <FsEventPoller.qm.dox.h>
Public Member Methods | |
constructor (string path, *hash< FsDelayedEventPollerOptionInfo > options) | |
Construct a file poller. More... | |
destructor () | |
Stops the event thread if it's running. | |
int | start () |
starts polling in the background; returns the thread ID of the polling thread More... | |
stop () | |
stops the polling operation, returns when the polling operation has been stopped More... | |
Public Member Methods inherited from FsEventPoller::AbstractFsEventPoller | |
constructor (string path, hash< AbstractFsEventPollerOptionInfo > options=< AbstractFsEventPollerOptionInfo >{}) | |
Construct a file poller. More... | |
abstract | fileEvent (hash< FsEventInfo > event) |
Abstract method called whenever soem filesystem event occurs. More... | |
Private Member Methods | |
hash< string, hash< FsEventInfo > > | m_cache () |
cache of events keyed by file path | |
Counter | m_start_counter (1) |
Counter that signals when the polling thread is running. | |
int | startIntern () |
Starts the background thread and returns the TID. | |
runBackground () | |
Processes file events in the background. | |
Private Member Methods inherited from FsEventPoller::AbstractFsEventPoller | |
setMask (string mask) | |
Set filesystem mask like in shell etc. More... | |
logInfo (string fmt) | |
calls the "log_info" closure or call reference with important information | |
logDetail (string fmt) | |
calls the "log_detail" closure or call reference with detail information | |
logDebug (string fmt) | |
calls the "log_debug" closure or call reference with verbose debugging information | |
initialRun (string path) | |
Called in the constructor to get already existing files/events. | |
Private Attributes | |
hash< string, date > | age_map |
cache of ages: file path -> last modified date | |
int | m_minage = 600 |
the minimum age for events in seconds | |
Delayed file notification handler.
The additional functionality of this class is to provide last modification timestamp check for affected files. The fileEvent()
method is invoked only if the last modification timestamp is older than value specified by file_poller_delayed_constructor_hash key minage
.
The example usecase can be when you need to communicate with applications which cannot write files atomically so your code needs to assume all is ready when the file is not modified in eg. 5 minutes.
Algorithm used:
stop()
method is calledFsEventPoller::AbstractDelayedFsEventPoller::constructor | ( | string | path, |
*hash< FsDelayedEventPollerOptionInfo > | options | ||
) |
Construct a file poller.
path | a string with full path to the directory to be monitored |
options | a hash with features settings; see FsDelayedEventPollerOptionInfo for details about this parameter |
int FsEventPoller::AbstractDelayedFsEventPoller::start | ( | ) |
starts polling in the background; returns the thread ID of the polling thread
if polling had already been started, then the thread ID of the polling thread is returned immediately
FsEventPoller::AbstractDelayedFsEventPoller::stop | ( | ) |
stops the polling operation, returns when the polling operation has been stopped
if polling was not in progress then this method returns immediately
THREAD-ERROR | this exception is thrown if this method is called from the event thread since it would result in a deadlock |