Struct OnDemandWorkerFunc

Run a job in a fiber, making sure never to run two simultaneously.

struct OnDemandWorkerFunc(alias F) ;

This semantics is useful for deferred jobs that need to collect or parse a state that changes. The number of jobs is not dependent on the number of state changes.

The usage is to trigger the worker when the state changes. If no job is currently running, a fiber is immediately launched to carry out the job. If the job is already running, it will trigger again once the current instance finishes.

Constructors

NameDescription
this Construct a worker

Properties

NameTypeDescription
spawned[get] boolReports whether a fiber is currently handling a request

Methods

NameDescription
cancel Cancel currently running tasks.
DEBUG Helper for more verbose DEBUG logging
disable Disable the worker from receiving new jobs.
enable Enable a disabled worker.
run Trigger an execution of the worker.
waitComplete Wait for all currently pending tasks to complete
waitIdle Wait for task queue to empty.