Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::app::PlotRenderPipeline Class Reference

Manages background SVG rasterization/generation worker thread, task queue, and caching. More...

#include <PlotRenderPipeline.hpp>

Collaboration diagram for correlation::app::PlotRenderPipeline:

Public Types

using ImageRenderedCallback = std::function<void(const slint::Image &)>

Public Member Functions

 PlotRenderPipeline (ImageRenderedCallback callback, bool dispatch_to_slint_event_loop=true)
 Constructs pipeline and starts background rendering worker thread.
 ~PlotRenderPipeline ()
 Destructor. Signals stop condition and joins worker thread safely.
 PlotRenderPipeline (const PlotRenderPipeline &)=delete
PlotRenderPipeline & operator= (const PlotRenderPipeline &)=delete
 PlotRenderPipeline (PlotRenderPipeline &&)=delete
PlotRenderPipeline & operator= (PlotRenderPipeline &&)=delete
bool isCacheHit (int index, const correlation::plotters::PlotConfig &config, const correlation::plotters::HoverInfo &hover, std::size_t pinned_runs_count, std::size_t active_frame=0) const noexcept
 Evaluates whether a new render request matches previously rendered frame parameters.
void invalidateCache () noexcept
 Invalidates cached parameters to force re-rendering on the next request.
void submitTask (RenderTask task)
 Enqueues a render task to the worker queue, discarding superseded tasks.
void stop () noexcept
 Stops worker thread and cancels pending operations.

Private Member Functions

std::optional< RenderTask > waitForNextTask ()
void dispatchImage (slint::Image img)
void renderLoop ()

Static Private Member Functions

static std::string renderSvg (RenderTask &task)

Private Attributes

ImageRenderedCallback callback_
bool dispatch_to_slint_event_loop_ {true}
std::jthread render_worker_
std::mutex render_mutex_
std::condition_variable render_cv_
std::optional< RenderTask > pending_task_
bool stop_render_worker_ {false}
std::shared_ptr< std::atomic< bool > > alive_ {std::make_shared<std::atomic<bool>>(true)}
std::mutex cache_mutex_
int last_rendered_index_ {-1}
std::size_t last_rendered_frame_ {0}
correlation::plotters::PlotConfig last_config_
correlation::plotters::HoverInfo last_hover_
std::size_t last_pinned_runs_count_ {0}

Detailed Description

Manages background SVG rasterization/generation worker thread, task queue, and caching.

Member Typedef Documentation

◆ ImageRenderedCallback

using correlation::app::PlotRenderPipeline::ImageRenderedCallback = std::function<void(const slint::Image &)>

Constructor & Destructor Documentation

◆ PlotRenderPipeline() [1/3]

correlation::app::PlotRenderPipeline::PlotRenderPipeline ( ImageRenderedCallback callback,
bool dispatch_to_slint_event_loop = true )
explicit

Constructs pipeline and starts background rendering worker thread.

Parameters
[in]callbackCallback invoked upon successful image generation.
[in]dispatch_to_slint_event_loopIf true, dispatches via slint::invoke_from_event_loop.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~PlotRenderPipeline()

correlation::app::PlotRenderPipeline::~PlotRenderPipeline ( )

Destructor. Signals stop condition and joins worker thread safely.

Here is the call graph for this function:

◆ PlotRenderPipeline() [2/3]

correlation::app::PlotRenderPipeline::PlotRenderPipeline ( const PlotRenderPipeline & )
delete
Here is the call graph for this function:

◆ PlotRenderPipeline() [3/3]

correlation::app::PlotRenderPipeline::PlotRenderPipeline ( PlotRenderPipeline && )
delete
Here is the call graph for this function:

Member Function Documentation

◆ dispatchImage()

void correlation::app::PlotRenderPipeline::dispatchImage ( slint::Image img)
private
Here is the caller graph for this function:

◆ invalidateCache()

void correlation::app::PlotRenderPipeline::invalidateCache ( )
noexcept

Invalidates cached parameters to force re-rendering on the next request.

Here is the caller graph for this function:

◆ isCacheHit()

bool correlation::app::PlotRenderPipeline::isCacheHit ( int index,
const correlation::plotters::PlotConfig & config,
const correlation::plotters::HoverInfo & hover,
std::size_t pinned_runs_count,
std::size_t active_frame = 0 ) const
nodiscardnoexcept

Evaluates whether a new render request matches previously rendered frame parameters.

Parameters
[in]indexTarget plot index.
[in]configTarget plot configuration.
[in]hoverTarget hover info.
[in]pinned_runs_countCurrent pinned comparison runs count.
[in]active_frameCurrent active trajectory frame index.
Returns
True if previous frame exactly matches and re-render is unnecessary.

◆ operator=() [1/2]

PlotRenderPipeline & correlation::app::PlotRenderPipeline::operator= ( const PlotRenderPipeline & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

PlotRenderPipeline & correlation::app::PlotRenderPipeline::operator= ( PlotRenderPipeline && )
delete
Here is the call graph for this function:

◆ renderLoop()

void correlation::app::PlotRenderPipeline::renderLoop ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderSvg()

std::string correlation::app::PlotRenderPipeline::renderSvg ( RenderTask & task)
staticnodiscardprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void correlation::app::PlotRenderPipeline::stop ( )
noexcept

Stops worker thread and cancels pending operations.

Here is the caller graph for this function:

◆ submitTask()

void correlation::app::PlotRenderPipeline::submitTask ( RenderTask task)

Enqueues a render task to the worker queue, discarding superseded tasks.

Parameters
[in]taskSelf-contained render payload.
Here is the caller graph for this function:

◆ waitForNextTask()

std::optional< RenderTask > correlation::app::PlotRenderPipeline::waitForNextTask ( )
nodiscardprivate
Here is the caller graph for this function:

Member Data Documentation

◆ alive_

std::shared_ptr<std::atomic<bool> > correlation::app::PlotRenderPipeline::alive_ {std::make_shared<std::atomic<bool>>(true)}
private

◆ cache_mutex_

std::mutex correlation::app::PlotRenderPipeline::cache_mutex_
mutableprivate

◆ callback_

ImageRenderedCallback correlation::app::PlotRenderPipeline::callback_
private

◆ dispatch_to_slint_event_loop_

bool correlation::app::PlotRenderPipeline::dispatch_to_slint_event_loop_ {true}
private

◆ last_config_

correlation::plotters::PlotConfig correlation::app::PlotRenderPipeline::last_config_
private

◆ last_hover_

correlation::plotters::HoverInfo correlation::app::PlotRenderPipeline::last_hover_
private

◆ last_pinned_runs_count_

std::size_t correlation::app::PlotRenderPipeline::last_pinned_runs_count_ {0}
private

◆ last_rendered_frame_

std::size_t correlation::app::PlotRenderPipeline::last_rendered_frame_ {0}
private

◆ last_rendered_index_

int correlation::app::PlotRenderPipeline::last_rendered_index_ {-1}
private

◆ pending_task_

std::optional<RenderTask> correlation::app::PlotRenderPipeline::pending_task_
private

◆ render_cv_

std::condition_variable correlation::app::PlotRenderPipeline::render_cv_
private

◆ render_mutex_

std::mutex correlation::app::PlotRenderPipeline::render_mutex_
private

◆ render_worker_

std::jthread correlation::app::PlotRenderPipeline::render_worker_
private

◆ stop_render_worker_

bool correlation::app::PlotRenderPipeline::stop_render_worker_ {false}
private

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