Polling
NihiloCore provides two complementary polling tools: UNihiloPollingTask
for C++ and Blueprint use via a fluent callback API, and UNihiloPollingLibrary
for a Blueprint latent node that suspends execution until a condition is met.
Polling is useful when you need to wait for a condition that has no event — for example, waiting for a
subsystem to finish initializing, a replication flag to arrive on the client, or an async asset load
to complete — without coupling the waiting code to the thing being waited on.
Polling Task
UNihiloPollingTask repeatedly evaluates a condition function on
a fixed interval and fires a completion callback when it returns true.
An optional timeout sets a hard deadline — if the condition hasn't been met by then, the timeout
callback fires instead.
The condition is evaluated immediately on start before the first interval tick. If it is already
true, the complete callback fires right away and no timers are started.
The task manages its own lifetime via AddToRoot — it keeps
itself alive until the condition is met, the timeout fires, or it is cancelled. After any of these,
it cleans up its timers, clears its delegates, and calls RemoveFromRoot.
You do not need to store it in a UPROPERTY to keep it alive, though
you may want to hold a reference if you intend to cancel it early.
C++ Usage
cpp
UNihiloPollingTask::Create(this, [this]()
{
return [True condition here]
})
->WithInterval(0.1f)
->WithTimeout(10.0f)
->OnComplete([this]()
{
[Runs when condition is met.]
});Blueprint Usage
Use CreateBP with a FPollingConditionDynamic
delegate instead of a native lambda. Chain WithInterval,
WithTimeout, OnComplete,
and OnTimeout the same way. In Blueprint, the completion and
timeout events are exposed as OnConditionMet and
OnTimeoutFired dynamic multicast delegates on the task object.
API
| Function | Description |
|---|---|
| Create | Creates a new task with a native TFunction<bool()> condition. C++ only. |
| CreateBP | Creates a new task with a FPollingConditionDynamic delegate condition. Blueprint compatible. |
| WithInterval | Sets the polling interval in seconds. Must be called before the task starts. Returns this for chaining. |
| WithTimeout | Sets the maximum duration before the timeout callback fires. Optional. Must be called before the task starts. Returns this for chaining. |
| OnComplete | Sets the callback to fire when the condition returns true. Calling this starts the task if it hasn't started yet. Returns this for chaining. |
| OnTimeout | Sets the callback to fire if the timeout elapses before the condition is met. Calling this also starts the task if it hasn't started yet. Returns this for chaining. |
| Cancel | Stops polling and clears all timers and delegates without firing any callback. |
Poll Until True (Latent Node)
PollUntilTrue in UNihiloPollingLibrary
is a Blueprint latent function that suspends execution at a node until a boolean condition becomes
true or a timeout is reached. It behaves like a Delay node but
driven by a condition rather than a fixed duration.
The node takes a boolean variable by reference, an interval, and an optional timeout. It evaluates
the boolean immediately on entry, then re-evaluates on every interval tick. When the condition is
met or the timeout elapses, execution resumes with a ENihiloPollResult
output — either Success or TimedOut —
so you can branch on the outcome.
The latent action guards against duplicate execution — if the node is somehow triggered again while
already running (e.g. called from a Tick), the second call is ignored and the existing action
continues unaffected.
For cases where you need callbacks or want to poll a computed expression rather than a plain
boolean variable, use UNihiloPollingTask instead.