Skip to content

Engine → Scripting → hot_reload.h

hot_reload_controller

Syntax

class CONJURE_API hot_reload_controller

Constructors

AccessSignatureDescription
publichot_reload_controller( script_runtime &runtime, std::filesystem::path assemblyPath);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~hot_reload_controller();

Variables

AccessNameTypeDefaultDescription
privatemAssemblyPathstd::filesystem::path{}
privatemDebounceSecondsf640.2
privatemHasWatchStampboolfalse
privatemImmediateboolfalse
privatemLastResultcore::result<void>core::result<void>::success()
privatemLastWatchTimef640.0
privatemReloadCountu320
privatemRequestCountu320
privatemRequestTimef640.0
privatemRuntimescript_runtime *nullptr
privatemStatereload_statereload_state::IDLE
privatemWatchIntervalSecondsf640.0
privatemWatchRetriesLeftu320
privatemWatchStampstd::filesystem::file_time_type{}
privatemWatchTriggeredboolfalse
privateWATCH_RETRY_LIMITstatic constexpr u323

Functions

Public

assembly_path

[[nodiscard]] const std::filesystem::path &assembly_path() const noexcept;

debounce_seconds

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

last_result

[[nodiscard]] const core::result<void> &last_result() const noexcept;

Outcome of the last reload tick() performed (success before any).

reload_count

[[nodiscard]] u32 reload_count() const noexcept;

Reload attempts tick() performed, including the retries of a failed watched reload.

request

void request(
    bool immediate = false);

Asks for a reload. Requests inside the debounce window coalesce into one; immediate makes the next tick() reload regardless of the window.

request_count

[[nodiscard]] u32 request_count() const noexcept;

request() calls received (coalesced or not).

set_assembly_path

void set_assembly_path(
    std::filesystem::path assemblyPath);

set_debounce_seconds

void set_debounce_seconds(
    f64 seconds) noexcept;

Seconds a request waits before tick() executes it (default 0.2).

set_watch_interval_seconds

void set_watch_interval_seconds(
    f64 seconds) noexcept;

Polls the write time of the assembly and of the .pdb next to it (the newer of the two) every seconds inside tick() and requests a reload when it changed; 0 (default) disables the watch. A reload the watch requested that fails with ASSEMBLY_LOAD_FAILED (a build still writing or locking the files) is retried up to 3 times, one debounce window apart (a WARN each); a reload asked for with request() is not retried.

state

[[nodiscard]] reload_state state() const noexcept;

tick

void tick(
    f64 nowSeconds);

Call once per frame before the first script phase with the frame time; performs a due reload (and polls the assembly file when watching).

watch_interval_seconds

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

Private

perform_reload

void perform_reload();

poll_assembly_file

void poll_assembly_file(
    f64 nowSeconds);