Unravel Engine C++ Reference
Loading...
Searching...
No Matches
watcher_fallback.h
Go to the documentation of this file.
1#ifndef FS_WATCHER_FALLBACK_H
2#define FS_WATCHER_FALLBACK_H
3
4#include <atomic>
5#include <chrono>
6#include <condition_variable>
7#include <functional>
8#include <map>
9#include <memory>
10#include <mutex>
11#include <string>
12#include <thread>
13
14#include "../filesystem.h"
15#include "../pattern_filter.h"
16#include "../watcher.h"
17
18namespace fs
19{
20
22{
23public:
24 //-----------------------------------------------------------------------------
25 // Name : ~watcher_fallback ()
31 //-----------------------------------------------------------------------------
33 watcher_fallback() = default;
34
35 //-----------------------------------------------------------------------------
36 // Name : watch_impl ()
42 //-----------------------------------------------------------------------------
43 auto watch_impl(const fs::path& path,
44 const pattern_filter& filter,
45 bool recursive,
46 bool initial_list,
47 watcher::clock_t::duration poll_interval,
49 const std::string& watcher_name) -> std::uint64_t;
50
51 void unwatch_impl(std::uint64_t key);
52
53 void unwatch_all_impl();
54
55 void pause();
56 void resume();
57
58 void wait_all(watcher::clock_t::duration duration);
59
60 //-----------------------------------------------------------------------------
61 // Name : close ()
67 //-----------------------------------------------------------------------------
68 void close();
69
70 //-----------------------------------------------------------------------------
71 // Name : start ()
77 //-----------------------------------------------------------------------------
78 void start();
79
81 std::mutex mutex_;
83 std::atomic<bool> watching_ = {false};
84
85 std::atomic<bool> globally_paused_ = {false};
86
87 std::condition_variable cv_;
89 std::thread thread_;
91 class impl;
92 std::map<std::uint64_t, std::shared_ptr<impl>> watchers_;
93
96 std::map<fs::path, std::shared_ptr<directory_listener>> directory_listeners_;
97
99};
100
101} // namespace fs
102
103#endif
A filter that combines include and exclude patterns for file/directory filtering.
watcher_fallback()=default
std::thread thread_
Thread that polls for changes.
auto watch_impl(const fs::path &path, const pattern_filter &filter, bool recursive, bool initial_list, watcher::clock_t::duration poll_interval, watcher::notify_callback callback, const std::string &watcher_name) -> std::uint64_t
std::atomic< bool > globally_paused_
std::atomic< bool > watching_
Atomic bool sync.
std::map< fs::path, std::shared_ptr< directory_listener > > directory_listeners_
std::condition_variable cv_
std::map< std::uint64_t, std::shared_ptr< impl > > watchers_
std::mutex mutex_
Mutex for the file watchers.
void unwatch_impl(std::uint64_t key)
void wait_all(watcher::clock_t::duration duration)
std::function< void(const std::vector< entry > &, bool)> notify_callback
Definition watcher.h:41
Definition cache.hpp:11