KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DB_JOB_CONTEXT Class Reference

What a job running on a DB_WORKER_THREAD uses to hand rows to the caller. More...

#include <db_worker_thread.h>

Public Member Functions

bool Emit (std::vector< DB_VALUE > &&aRow)
 Queues a row for the caller's sink.
 
bool Flush ()
 Delivers the rows still held back and waits until the caller's sink has taken every one.
 
bool Cancelled () const
 

Static Public Attributes

static constexpr size_t BATCH_ROWS = 512
 
static constexpr size_t MAX_QUEUED_BATCHES = 4
 

Private Member Functions

 DB_JOB_CONTEXT (DB_WORKER_CORE &aCore)
 
bool pushBatch ()
 

Private Attributes

DB_WORKER_CORE & m_core
 
std::vector< std::vector< DB_VALUE > > m_pending
 

Friends

struct DB_WORKER_CORE
 

Detailed Description

What a job running on a DB_WORKER_THREAD uses to hand rows to the caller.

Rows are grouped in batches of BATCH_ROWS, and at most MAX_QUEUED_BATCHES wait for the caller at once, so a table is never copied in full.

Definition at line 43 of file db_worker_thread.h.

Constructor & Destructor Documentation

◆ DB_JOB_CONTEXT()

DB_JOB_CONTEXT::DB_JOB_CONTEXT ( DB_WORKER_CORE & aCore)
inlineexplicitprivate

Definition at line 69 of file db_worker_thread.h.

References DB_WORKER_CORE, and m_core.

Member Function Documentation

◆ Cancelled()

bool DB_JOB_CONTEXT::Cancelled ( ) const
Returns
true once the caller's sink rejected a batch or the caller gave up on the job

Definition at line 256 of file db_worker_thread.cpp.

References m_core.

Referenced by Emit(), Flush(), and pushBatch().

◆ Emit()

bool DB_JOB_CONTEXT::Emit ( std::vector< DB_VALUE > && aRow)

Queues a row for the caller's sink.

Blocks while the caller is behind.

Returns
false once the caller's sink rejected a batch or the caller gave up on the job; the job must then stop and undo its work

Definition at line 288 of file db_worker_thread.cpp.

References BATCH_ROWS, Cancelled(), m_pending, and pushBatch().

Referenced by SQLITE_BACKEND::ReadTable().

◆ Flush()

bool DB_JOB_CONTEXT::Flush ( )

Delivers the rows still held back and waits until the caller's sink has taken every one.

A job commits only after this returns true.

Definition at line 299 of file db_worker_thread.cpp.

References Cancelled(), m_core, m_pending, and pushBatch().

Referenced by SQLITE_BACKEND::ReadTable().

◆ pushBatch()

bool DB_JOB_CONTEXT::pushBatch ( )
private

Definition at line 262 of file db_worker_thread.cpp.

References BATCH_ROWS, Cancelled(), m_core, m_pending, and MAX_QUEUED_BATCHES.

Referenced by Emit(), Flush(), and DB_WORKER_CORE::Main().

Friends And Related Symbol Documentation

◆ DB_WORKER_CORE

friend struct DB_WORKER_CORE
friend

Definition at line 67 of file db_worker_thread.h.

References DB_WORKER_CORE.

Referenced by DB_JOB_CONTEXT(), and DB_WORKER_CORE.

Member Data Documentation

◆ BATCH_ROWS

size_t DB_JOB_CONTEXT::BATCH_ROWS = 512
staticconstexpr

Definition at line 46 of file db_worker_thread.h.

Referenced by Emit(), and pushBatch().

◆ m_core

DB_WORKER_CORE& DB_JOB_CONTEXT::m_core
private

Definition at line 73 of file db_worker_thread.h.

Referenced by Cancelled(), DB_JOB_CONTEXT(), Flush(), and pushBatch().

◆ m_pending

std::vector<std::vector<DB_VALUE> > DB_JOB_CONTEXT::m_pending
private

Definition at line 74 of file db_worker_thread.h.

Referenced by Emit(), Flush(), DB_WORKER_CORE::Main(), and pushBatch().

◆ MAX_QUEUED_BATCHES

size_t DB_JOB_CONTEXT::MAX_QUEUED_BATCHES = 4
staticconstexpr

Definition at line 47 of file db_worker_thread.h.

Referenced by pushBatch().


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