Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
Mads::Watcher Class Reference

#include <watcher.hpp>

Public Member Functions

 Watcher (const std::string &file_name, std::chrono::duration< float > to=0s)
 
 ~Watcher ()
 
void watch (const std::function< void(const std::string &)> &callback)
 Watch the file, invoking the callback on each modification.
 
void stop ()
 Ask a running watch() loop to return.
 

Detailed Description

Definition at line 31 of file watcher.hpp.

Constructor & Destructor Documentation

◆ Watcher()

Mads::Watcher::Watcher ( const std::string &  file_name,
std::chrono::duration< float >  to = 0s 
)
inline

Definition at line 33 of file watcher.hpp.

◆ ~Watcher()

Mads::Watcher::~Watcher ( )
inline

Definition at line 60 of file watcher.hpp.

Member Function Documentation

◆ stop()

void Mads::Watcher::stop ( )
inline

Ask a running watch() loop to return.

Safe to call from any thread; watch() returns within its current wait (bounded to about a second) plus the 200 ms poll interval.

Definition at line 95 of file watcher.hpp.

◆ watch()

void Mads::Watcher::watch ( const std::function< void(const std::string &)> &  callback)
inline

Watch the file, invoking the callback on each modification.

Blocks the calling thread until stop() is called (typically from another thread) or a process-wide stop is requested (Mads::Runtime::stop_process(), e.g. on SIGINT). Platform waits are bounded, so the loop notices a stop request within about a second.

Definition at line 81 of file watcher.hpp.


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