Home Documentation Tutorials API GitHub

All Types

abstract const class studs::Daemon

sys::Obj
  studs::Daemon

Daemon provides an API for long-running system services running on their own thread with life-cycle callbacks for start, stop, poll, and custom messages.

See Daemons chapter for details.

log

const Log log

Log for this daemon.

make

new make(Duration? pollFreq)

Subclass constructor where pollFreq is the frequency to invoke onPoll callback, or null to not schedule a poll callback.

name

Str name()

Programmtic name of this daemon, which by convention is simply the type name lowercased.

onMsg

protected virtual Obj? onMsg(DaemonMsg m)

Callback to process a daemon message.

onPoll

protected virtual Void onPoll()

Callback when periodic poll is dispatched.

onStart

protected virtual Void onStart()

Callback when daemon is started.

onStop

protected virtual Void onStop()

Callback when daemon is stopped.

send

Future send(DaemonMsg m)

Send this daemon a message.

start

This start()

Start this daemon instance. This method is guaranteed not to throw an exception (but will log errors to log). Any error handling required should be implemented inside the onStart override method.