Runner

class Runner

Many of the classes in libsemigroups implementing the algorithms, that are the reason for the existence of this library, are derived from Runner.

The Runner class exists to collect various common tasks required by such a derived class with a possibly long running run. These common tasks include:

  • running for a given amount of time (run_for)

  • running until a nullary predicate is true (run_until)

  • reporting after a given amount of time (report_every)

  • checking if the given amount of time has elapsed since last report (report)

  • checking the status of the algorithm: has it started? finished? been killed by another thread (dead)? has it timed out (timed_out)? has it stopped for any reason?

  • permit the function run to be killed from another thread (kill).

Subclassed by libsemigroups::Action< TElementType, TPointType, TActionType, TTraits, TLeftOrRight >, libsemigroups::CongruenceInterface, libsemigroups::FpSemigroupInterface, libsemigroups::FroidurePinBase, libsemigroups::Konieczny< TElementType, TTraits >

Constructors

Runner()

Default constructor.

Runner(Runner const&)

Copy constructor.

Runner(Runner&&)

Move constructor.

Deleted constructors

operator=(Runner const&) = delete

Deleted.

operator=(Runner&&) = delete

Deleted.

Reporting

report() const

Check if it is time to report.

report_every() const noexcept

Get the minimum elapsed time between reports.

report_every(TIntType)

Set the minimum elapsed time between reports.

report_every(std::chrono::nanoseconds)

Set the minimum elapsed time between reports.

report_why_we_stopped() const

Report why run stopped.

State

dead() const noexcept

Check if the runner is dead.

finished() const

Check if run has been run to completion or not.

running() const noexcept

Check if currently running.

started() const

Check if run has been called at least once before.

stopped() const

Check if the runner is stopped.

stopped_by_predicate() const

Check if the runner was, or should, stop because of the argument for run_until .

timed_out() const

Check if the amount of time passed to run_for has elapsed.

Operators

kill() noexcept

Stop run from running (thread-safe).

run()

Run until finished .

run_for(TIntType)

Run for a specified amount of time.

run_for(std::chrono::nanoseconds)

Run for a specified amount of time.

run_until(T&&)

Run until a nullary predicate returns true or finished .

run_until(bool(*)())

Run until a nullary predicate returns true or finished .

running_for() const noexcept

Check if the runner is currently running for a particular length of time.

running_until() const noexcept

Check if the runner is currently running until a nullary predicate returns true.