class

Mosquito::Runner

Inherits Reference < Object

This singleton class serves as a shorthand for starting and managing an Overseer.

A minimal usage of Mosquito::Runner is:

require "mosquito"

# When the process receives sigint, it'll notify the overseer to shut down gracefully.
trap("INT") do
  Mosquito::Runner.stop(wait: true)
end

# Starts the overseer, and holds the thread captive.
Mosquito::Runner.start

If for some reason you want to manage an overseer or group of overseers yourself, Mosquito::Runner can be omitted entirely:

require "mosquito"

mosquito = Mosquito::Overseer.new

# Spawns a mosquito managed fiber and returns immediately
mosquito.run

trap "INT" do
  mosquito.stop.receive
end

Constants

Log = ::Log.for(self)

Class methods

start(spin = true)

Start the mosquito runner.

If spin = true (default) the function will not return until the runner is shut down. Otherwise it will return immediately.

Source
stop(wait = false)

Request the mosquito runner stop. The runner will not abort the current job but it will not start any new jobs.

See Mosquito::Runnable#stop.

Source