Skip to content

ludus::foundation::threading::JobSystemHooks

Ludus Wiki · API overview · Browse API

Struct

Optional observers of a JobSystem, fixed at Initialize.
Every hook runs outside the scheduler gate and must not block on jobs. A hook that calls JobSystem Initialize, Submit, Wait or Shutdown receives InsideJob; destroying a system or a submitted graph from a hook is a fatal contract violation. Hooks must not fail the scheduler: report or drop their own errors. The hook code and the data ContextOrNull references must outlive the system. With no hooks the scheduler performs no extra work; with TraceOrNull set and the filter declining a submission, each job costs one extra predictable branch.

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp

#include <ludus/foundation/threading/jobs.hpp>
struct ludus::foundation::threading::JobSystemHooks

Fields

WorkerStartOrNull

JobWorkerFunction ludus::foundation::threading::JobSystemHooks::WorkerStartOrNull = nullptr
Runs once on each worker before it takes work; Initialize returns after every call returned.
Use it to register threads with a profiler or to initialize thread-local state.

Related types: JobWorkerFunction

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp

WorkerStopOrNull

JobWorkerFunction ludus::foundation::threading::JobSystemHooks::WorkerStopOrNull = nullptr
Runs once on each worker after it stops taking work, before Shutdown joins it.

Related types: JobWorkerFunction

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp

TraceOrNull

JobTraceFunction ludus::foundation::threading::JobSystemHooks::TraceOrNull = nullptr
Receives the transitions of each traced submission; null disables tracing.
For a submission, every call returns before Wait releases it, except WaitReturned, which Wait reports after the release and before it returns. Started, Signalled and Finished are reported by the thread that runs the job, around its callback, so an event's Label is valid during the call.

Related types: JobTraceFunction

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp

ShouldTraceOrNull

JobTraceFilterFunction ludus::foundation::threading::JobSystemHooks::ShouldTraceOrNull = nullptr
Decides per Submit whether TraceOrNull observes it; null traces every submission.

Related types: JobTraceFilterFunction

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp

ContextOrNull

void* ludus::foundation::threading::JobSystemHooks::ContextOrNull = nullptr
Passed to every hook. Not owned.

Declared in modules/foundation/threading/include/ludus/foundation/threading/jobs.hpp