Class MemoryBackgroundTasks
java.lang.Object
io.agentscope.harness.agent.memory.MemoryBackgroundTasks
Tracks in-flight fire-and-forget memory background tasks (flush, maintenance) so
HarnessAgent.close() can wait for them to quiesce before releasing resources.
The middleware instances that dispatch these tasks are created per agent call, so they
cannot be reached from the agent's close() method. Like
SessionTree.awaitMirrorQuiescence(long, java.util.concurrent.TimeUnit), the
in-flight count is process-wide: close() blocks until every background task started
before the call has finished, so async workspace writes do not race with resource cleanup
(e.g. temp workspace deletion in tests).
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanawaitQuiescence(long timeout, TimeUnit unit) Blocks until all background tasks started before this call have finished, or the timeout elapses.static voidbegin()Marks the start of a fire-and-forget background task.static voidend()Marks the end of a fire-and-forget background task (must pair withbegin()).
-
Method Details
-
begin
public static void begin()Marks the start of a fire-and-forget background task. -
end
public static void end()Marks the end of a fire-and-forget background task (must pair withbegin()). -
awaitQuiescence
Blocks until all background tasks started before this call have finished, or the timeout elapses.- Parameters:
timeout- maximum time to waitunit- time unit oftimeout- Returns:
trueif the tasks quiesced within the timeout
-