# The TaskRunner

The task runner runs long-running operations on a puzzle. It is used
to run operations that take more than a frame to complete. Currently,
there are three tasks that use it: The [Word Solver](word-solver.md),
the Anagram Solver, and the Theme Word fitter.

## API and State

 * `task_runner_run()`: Transitions to RUNNING. Initializes a new
 TaskContext. If a previous COMPLETE task existed, it is reset first.
 * `task_runner_cancel()`: Cancels the task. The task enters the
   COMPLETE state upon yielding. Results collected up to the
   cancellation point remain accessible via
   `task_runner_get_result()`.
 * `task_runner_reset()`: Immediately transitions the runner to
   READY. If a thread is active, it is cancelled and marked for
   background cleanup; its results become inaccessible immediately.
