Simplify the Job Queue:

This is a refactor aimed at cleaning up and simplifying the existing
job queue.

As of now, all jobs are cancelled at the same time and in the same
way, so this commit removes the per-job cancellation token. If the
need for such support is demonstrated, support can be re-added.

* Revise documentation for ClosureCounter and Workers.
* Simplify code, removing unnecessary function arguments and
  deduplicating expressions
* Restructure job handlers to no longer need to pass a job's
  handle to the job.
This commit is contained in:
John Freeman
2021-11-16 10:55:52 -06:00
committed by Nik Bougalis
parent df02eb125f
commit c2a08a1f26
31 changed files with 164 additions and 242 deletions

View File

@@ -31,21 +31,21 @@ namespace ripple {
/**
* The role of a `ClosureCounter` is to assist in shutdown by letting callers
* wait for the completion of callbacks (of a single type signature) that they
* previously scheduled. The lifetime of a `ClosureCounter` consists of two
* wait for the completion of closures (of a specific type signature) that they
* previously registered. These closures are typically callbacks for
* asynchronous operations. The lifetime of a `ClosureCounter` consists of two
* phases: the initial expanding "fork" phase, and the subsequent shrinking
* "join" phase.
*
* In the fork phase, callers register a callback by passing the callback and
* In the fork phase, callers register a closure by passing the closure and
* receiving a substitute in return. The substitute has the same callable
* interface as the callback, and it informs the `ClosureCounter` whenever it
* interface as the closure, and it informs the `ClosureCounter` whenever it
* is copied or destroyed, so that it can keep an accurate count of copies.
*
* The transition to the join phase is made by a call to `join`. In this
* phase, every substitute returned going forward will be empty, signaling to
* the caller that they should just drop the callback and cancel their
* asynchronous operation. `join` blocks until all existing callback
* substitutes are destroyed.
* phase, every substitute returned going forward will be null, signaling to
* the caller that they should drop the closure and cancel their operation.
* `join` blocks until all existing closure substitutes are destroyed.
*
* \tparam Ret_t The return type of the closure.
* \tparam Args_t The argument types of the closure.