morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::table::detail::ViewJob Class Reference

One recomputation of a view, runnable in steps. More...

#include <engine.hpp>

Public Member Functions

 ViewJob (JobInput input)
 Prepares a job.
bool step (Deadline deadline, ::core::async::StopToken const &stop)
 Runs until done, the deadline, or a stop request.
void onPhase (std::function< void(std::size_t, std::size_t)> listener)
 Sets a receiver of (phases done, total) after each phase ends, on the thread that runs the step.
std::pair< std::size_t, std::size_t > progress () const noexcept
 Phases done and total, for a progress sink.
bool done () const noexcept
 Whether every phase has run.
std::optional< std::string > const & failure () const noexcept
 Why the job failed: the message of the exception that ended it.
JobInput const & input () const noexcept
 What the job reads.
JobResult takeResult ()
 Moves the result out. Valid once done(); the input stays readable.

Detailed Description

One recomputation of a view, runnable in steps.

Phases: build missing keys (or patch the keys of dirty rows), then either repair the previous order, or filter and sort, then diff against the previous view. step returns at a deadline or a stop request and resumes where it stopped.

Definition at line 283 of file engine.hpp.

Constructor & Destructor Documentation

◆ ViewJob()

morph::table::detail::ViewJob::ViewJob ( JobInput input)
inlineexplicit

Prepares a job.

Parameters
inputEverything it reads.

Definition at line 287 of file engine.hpp.

Member Function Documentation

◆ step()

bool morph::table::detail::ViewJob::step ( Deadline deadline,
::core::async::StopToken const & stop )
inline

Runs until done, the deadline, or a stop request.

An exception from an injected service (a collator, date parser or comparator) ends the job: it is done, with failure() set.

Parameters
deadlineWhen to yield.
stopA stop request ends the step.
Returns
true when the job is done.

Definition at line 299 of file engine.hpp.

◆ onPhase()

void morph::table::detail::ViewJob::onPhase ( std::function< void(std::size_t, std::size_t)> listener)
inline

Sets a receiver of (phases done, total) after each phase ends, on the thread that runs the step.

Parameters
listenerThe receiver.

Definition at line 314 of file engine.hpp.

◆ progress()

std::pair< std::size_t, std::size_t > morph::table::detail::ViewJob::progress ( ) const
inlinenodiscardnoexcept

Phases done and total, for a progress sink.

Returns
(done, total).

Definition at line 318 of file engine.hpp.

◆ done()

bool morph::table::detail::ViewJob::done ( ) const
inlinenodiscardnoexcept

Whether every phase has run.

Returns
true when done.

Definition at line 324 of file engine.hpp.

◆ failure()

std::optional< std::string > const & morph::table::detail::ViewJob::failure ( ) const
inlinenodiscardnoexcept

Why the job failed: the message of the exception that ended it.

Returns
The message, or nothing when the job did not fail.

Definition at line 328 of file engine.hpp.

◆ input()

JobInput const & morph::table::detail::ViewJob::input ( ) const
inlinenodiscardnoexcept

What the job reads.

Returns
The input.

Definition at line 332 of file engine.hpp.

◆ takeResult()

JobResult morph::table::detail::ViewJob::takeResult ( )
inlinenodiscard

Moves the result out. Valid once done(); the input stays readable.

Returns
The result.

Definition at line 336 of file engine.hpp.


The documentation for this class was generated from the following file: