Class UnitsOfWork
java.lang.Object
com.kingsrook.qqq.backend.core.instrumentation.UnitsOfWork
Opens and closes
UnitOfWorks on the current thread.
Units nest: the outermost unit owns every statement run while it is open
(a process run inside an HTTP request belongs to that request; a scheduled
job's process belongs to the job). Only the outermost unit's end is
reported to listeners. Scopes do nothing (and return a shared no-op) while
no statement listener is registered.
try(UnitsOfWork.Scope scope = UnitsOfWork.begin(UnitOfWorkKind.SCHEDULED_JOB, processName)) { ... }
Units are per thread: work handed to another thread is not part of the unit
(statements there are still attributed by process through the action stack).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA begun unit or nested scope. -
Method Summary
Modifier and TypeMethodDescriptionstatic UnitsOfWork.Scopebegin(UnitOfWorkKind kind, String name) Begin a unit (or a nested scope inside the open one).static UnitOfWorkcurrent()The outermost open unit on this thread, or null.static voidreset()Drop any unit left open on this thread (for thread pools, before a new request), without reporting it.
-
Method Details
-
begin
Begin a unit (or a nested scope inside the open one). Close the returned scope exactly once, in a finally block or try-with-resources. -
current
The outermost open unit on this thread, or null. -
reset
public static void reset()Drop any unit left open on this thread (for thread pools, before a new request), without reporting it.
-