Skip to content

Engine → Assets → file_watcher.h

polling_file_watcher

Syntax

class CONJURE_API polling_file_watcher final : public file_watcher

Inheritance Hierarchy

file_watcher → polling_file_watcher

Constructors

AccessSignatureDescription
publicpolling_file_watcher( core::vfs::file_system &fileSystem, core::jobs::job_system &jobs, f64 intervalSeconds = DEFAULT_WATCH_INTERVAL_SECONDS);Watches through fileSystem and runs its passes on jobs. intervalSeconds is the least time between two passes poll() starts; with 0 every poll() starts one once the previous pass has finished. NaN and negative values count as 0, values above 1e9 seconds (infinity included) as 1e9.

Destructors

AccessSignatureDescription
public~polling_file_watcher() override;

Variables

AccessNameTypeDefaultDescription
privatemFileSystemcore::vfs::file_system *nullptr
privatemHasBaselineboolfalse
privatemHasPassedboolfalse
privatemIntervalstd::chrono::steady_clock::duration{}
privatemIntervalSecondsf64DEFAULT_WATCH_INTERVAL_SECONDS
privatemJobscore::jobs::job_system *nullptr
privatemLastPassFailurestd::string{}
privatemLastPassStartstd::chrono::steady_clock::time_point{}
privatemMutexstd::mutex{}
privatemPasscore::jobs::job_handle{}
privatemPassResultcore::flat_hash_map<std::string, file_state>{}
privatemPassResultReadyboolfalse
privatemPendingcore::flat_hash_map<std::string, file_state>{}
privatemPendingRemovalcore::flat_hash_map<std::string, bool>{}
privatemReadystd::vector<file_change>{}
privatemRootsstd::vector<std::string>{}
privatemSnapshotcore::flat_hash_map<std::string, file_state>{}

Functions

Public

add_root

void add_root(
    std::string_view rootPath) override;

interval_seconds

[[nodiscard]] f64 interval_seconds() const noexcept;

The interval between passes in seconds, as the constructor clamped it.

poll

void poll(
    std::vector<file_change> &outChanges) override;

scan_now

[[nodiscard]] core::result<void> scan_now();

One synchronous stat pass on the caller; changes become visible to the next poll(). Fails when a root cannot be enumerated.

snapshot

[[nodiscard]] core::result<void> snapshot() override;

tracked_file_count

[[nodiscard]] usize tracked_file_count() const noexcept;

Private

apply_pass

void apply_pass(
    core::flat_hash_map<std::string, file_state> &&current);

stat_roots

[[nodiscard]] core::result<core::flat_hash_map<std::string, file_state>> stat_roots() const;