Engine → Scripting → hot_reload.h
hot_reload_controller
| Type | Class |
| Namespace | conjure::scripting |
| Include File Path | engine/include/conjure/scripting/hot_reload.h |
| Source File Path | engine/src/scripting/hot_reload.cpp |
| API ↗ | Hosting, the native API and hot reload, Scripting |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | hot_reload_controller(
script_runtime &runtime,
std::filesystem::path assemblyPath); |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~hot_reload_controller(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | m | std::filesystem::path | {} | |
| private | m | f64 | 0.2 | |
| private | m | bool | false | |
| private | mImmediate | bool | false | |
| private | mLastResult | core::result<void> | core:: | |
| private | m | f64 | 0.0 | |
| private | mReloadCount | u32 | 0 | |
| private | m | u32 | 0 | |
| private | mRequestTime | f64 | 0.0 | |
| private | mRuntime | script_runtime * | nullptr | |
| private | mState | reload_state | reload_ | |
| private | m | f64 | 0.0 | |
| private | m | u32 | 0 | |
| private | mWatchStamp | std:: | {} | |
| private | m | bool | false | |
| private | WATCH_ | static constexpr u32 | 3 |
Functions
Public
assembly_path
assembly_path[[nodiscard]] const std::filesystem::path &assembly_path() const noexcept;debounce_seconds
debounce_seconds[[nodiscard]] f64 debounce_seconds() const noexcept;last_result
last_result[[nodiscard]] const core::result<void> &last_result() const noexcept;Outcome of the last reload tick() performed (success before any).
reload_count
reload_count[[nodiscard]] u32 reload_count() const noexcept;Reload attempts tick() performed, including the retries of a failed watched reload.
request
requestvoid 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
request_count[[nodiscard]] u32 request_count() const noexcept;request() calls received (coalesced or not).
set_assembly_path
set_assembly_pathvoid set_assembly_path(
std::filesystem::path assemblyPath);set_debounce_seconds
set_debounce_secondsvoid set_debounce_seconds(
f64 seconds) noexcept;Seconds a request waits before tick() executes it (default 0.2).
set_watch_interval_seconds
set_watch_interval_secondsvoid 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
state[[nodiscard]] reload_state state() const noexcept;tick
tickvoid 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
watch_interval_seconds[[nodiscard]] f64 watch_interval_seconds() const noexcept;Private
perform_reload
perform_reloadvoid perform_reload();poll_assembly_file
poll_assembly_filevoid poll_assembly_file(
f64 nowSeconds);