proxygen
|
#include <FilePoller.h>
Classes | |
struct | FileData |
struct | FileModificationData |
class | ThreadProtector |
Public Types | |
using | Cob = std::function< void()> |
using | Condition = std::function< bool(const FileModificationData &, const FileModificationData &)> |
Public Member Functions | |
FilePoller (std::chrono::milliseconds pollInterval=kDefaultPollInterval) | |
virtual | ~FilePoller () |
FilePoller (const FilePoller &other)=delete | |
FilePoller & | operator= (const FilePoller &other)=delete |
FilePoller (FilePoller &&other)=delete | |
FilePoller && | operator= (FilePoller &&other)=delete |
void | addFileToTrack (const std::string &fileName, Cob yCob, Cob nCob=nullptr, Condition condition=fileTouchedCondInternal) |
void | removeFileToTrack (const std::string &fileName) |
void | stop () |
Static Public Member Functions | |
static Condition | fileTouchedWithinCond (std::chrono::seconds expireTime) |
static Condition | doAlwaysCond () |
static Condition | fileTouchedCond () |
Protected Member Functions | |
virtual FileModificationData | getFileModData (const std::string &path) noexcept |
Private Types | |
using | FileDatas = std::unordered_map< std::string, FileData > |
Private Member Functions | |
void | checkFiles () noexcept |
void | initFileData (const std::string &fName, FileData &fData) noexcept |
void | init (std::chrono::milliseconds pollInterval) |
Static Private Member Functions | |
static bool | fileTouchedWithinCondInternal (const FilePoller::FileModificationData &, const FilePoller::FileModificationData &fModData, std::chrono::seconds expireTime) |
static bool | doAlwaysCondInternal (const FileModificationData &, const FileModificationData &) |
static bool | fileTouchedCondInternal (const FileModificationData &oldModData, const FileModificationData &modData) |
Private Attributes | |
FileDatas | fileDatum_ |
std::mutex | filesMutex_ |
uint64_t | pollerId_ {0} |
std::shared_ptr< folly::FunctionScheduler > | scheduler_ |
Static Private Attributes | |
static constexpr std::chrono::milliseconds | kDefaultPollInterval |
Polls for updates in the files. This poller uses modified times to track changes in the files, so it is the responsibility of the caller to check whether the contents have actually changed. It also assumes that when the file is modified, the modfied time changes. This is a reasonable assumption to make, so it should not be used in situations where files may be modified without changing the modified time.
Definition at line 41 of file FilePoller.h.
using wangle::FilePoller::Cob = std::function<void()> |
Definition at line 50 of file FilePoller.h.
using wangle::FilePoller::Condition = std::function< bool(const FileModificationData&, const FileModificationData&)> |
Definition at line 54 of file FilePoller.h.
|
private |
Definition at line 113 of file FilePoller.h.
|
explicit |
Definition at line 65 of file FilePoller.cpp.
References folly::init().
|
virtual |
|
delete |
|
delete |
void wangle::FilePoller::addFileToTrack | ( | const std::string & | fileName, |
Cob | yCob, | ||
Cob | nCob = nullptr , |
||
Condition | condition = fileTouchedCondInternal |
||
) |
Definition at line 115 of file FilePoller.cpp.
Referenced by wangle::MultiFilePoller::registerFiles(), and TEST_F().
|
privatenoexcept |
Definition at line 92 of file FilePoller.cpp.
References folly::pushmi::__adl::tp.
Referenced by fileTouchedCondInternal().
|
inlinestatic |
Definition at line 88 of file FilePoller.h.
References doAlwaysCondInternal().
|
inlinestaticprivate |
Definition at line 123 of file FilePoller.h.
Referenced by doAlwaysCond().
|
inlinestatic |
Definition at line 92 of file FilePoller.h.
References fileTouchedCondInternal(), getFileModData(), folly::pushmi::__adl::noexcept(), and string.
|
inlinestaticprivate |
Definition at line 129 of file FilePoller.h.
References checkFiles(), wangle::FilePoller::FileModificationData::exists, init(), initFileData(), wangle::FilePoller::FileModificationData::modTime, folly::pushmi::__adl::noexcept(), and string.
Referenced by fileTouchedCond().
|
inlinestatic |
Definition at line 80 of file FilePoller.h.
References folly::netops::bind(), and fileTouchedWithinCondInternal().
|
inlinestaticprivate |
Definition at line 115 of file FilePoller.h.
References wangle::FilePoller::FileModificationData::exists, wangle::FilePoller::FileModificationData::modTime, and folly::detail::distributed_mutex::time().
Referenced by fileTouchedWithinCond().
|
protectedvirtualnoexcept |
Reimplemented in NoDiskPoller.
Definition at line 146 of file FilePoller.cpp.
References deadlock::info().
Referenced by fileTouchedCond().
|
private |
Definition at line 71 of file FilePoller.cpp.
References context.
Referenced by fileTouchedCondInternal().
|
privatenoexcept |
Definition at line 107 of file FilePoller.cpp.
Referenced by fileTouchedCondInternal().
|
delete |
|
delete |
void wangle::FilePoller::removeFileToTrack | ( | const std::string & | fileName | ) |
Definition at line 133 of file FilePoller.cpp.
Referenced by wangle::MultiFilePoller::cancelCallback().
void wangle::FilePoller::stop | ( | ) |
Definition at line 85 of file FilePoller.cpp.
|
private |
Definition at line 143 of file FilePoller.h.
|
private |
Definition at line 146 of file FilePoller.h.
|
staticprivate |
Definition at line 100 of file FilePoller.h.
|
private |
Definition at line 148 of file FilePoller.h.
|
private |
Definition at line 153 of file FilePoller.h.