KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DB_WORKER_CORE Struct Reference

State shared by the owner and the worker thread; the thread keeps it alive after the owner is gone. More...

Public Types

typedef std::vector< std::vector< DB_VALUE > > BATCH
 

Public Member Functions

void wake ()
 Wakes the owner and the worker, which may be waiting in either kind of wait.
 
template<typename PRED>
void workerWait (std::unique_lock< std::mutex > &aLock, PRED aReady)
 Waits on the worker thread for aReady with m held, dispatching window messages meanwhile if asked to.
 
void abandon ()
 Marks the running job as given up on, with m held by the caller.
 
void releaseSlot ()
 Returns the job's admission slot, with m held by the caller.
 

Static Public Member Functions

static void Main (std::shared_ptr< DB_WORKER_CORE > aCore, std::function< bool()> aInit, std::function< void()> aExit)
 The thread body; owns aCore until the thread ends.
 

Public Attributes

std::string key
 
std::mutex m
 
std::condition_variable cv
 
std::function< void(DB_JOB_CONTEXT &)> job
 
bool hasJob = false
 
bool busy = false
 
bool done = false
 
bool stop = false
 
std::atomic< bool > initFailed { false }
 
std::atomic< bool > abandoned { false }
 
std::atomic< bool > rejected { false }
 
bool exited = false
 Set once the exit hook has returned.
 
bool slotHeld = false
 
std::deque< BATCH > queue
 
size_t pushed = 0
 
size_t consumed = 0
 
std::exception_ptr error
 
bool pumpMessages = false
 Windows only, the worker dispatches window messages whenever it waits.
 

Detailed Description

State shared by the owner and the worker thread; the thread keeps it alive after the owner is gone.

Definition at line 126 of file db_worker_thread.cpp.

Member Typedef Documentation

◆ BATCH

typedef std::vector<std::vector<DB_VALUE> > DB_WORKER_CORE::BATCH

Definition at line 128 of file db_worker_thread.cpp.

Member Function Documentation

◆ abandon()

void DB_WORKER_CORE::abandon ( )
inline

Marks the running job as given up on, with m held by the caller.

Definition at line 214 of file db_worker_thread.cpp.

References abandoned, key, m, and wake().

◆ Main()

void DB_WORKER_CORE::Main ( std::shared_ptr< DB_WORKER_CORE > aCore,
std::function< bool()> aInit,
std::function< void()> aExit )
static

The thread body; owns aCore until the thread ends.

Definition at line 316 of file db_worker_thread.cpp.

References abandoned, busy, done, error, exited, hasJob, initFailed, job, key, m, DB_JOB_CONTEXT::m_pending, DB_JOB_CONTEXT::pushBatch(), releaseSlot(), stop, wake(), and workerWait().

Referenced by DB_WORKER_THREAD::runJob().

◆ releaseSlot()

void DB_WORKER_CORE::releaseSlot ( )
inline

Returns the job's admission slot, with m held by the caller.

Definition at line 227 of file db_worker_thread.cpp.

References key, and slotHeld.

Referenced by Main().

◆ wake()

void DB_WORKER_CORE::wake ( )
inline

Wakes the owner and the worker, which may be waiting in either kind of wait.

Definition at line 163 of file db_worker_thread.cpp.

References cv, and pumpMessages.

Referenced by abandon(), and Main().

◆ workerWait()

template<typename PRED>
void DB_WORKER_CORE::workerWait ( std::unique_lock< std::mutex > & aLock,
PRED aReady )
inline

Waits on the worker thread for aReady with m held, dispatching window messages meanwhile if asked to.

Definition at line 175 of file db_worker_thread.cpp.

References cv, message, and pumpMessages.

Referenced by Main().

Member Data Documentation

◆ abandoned

std::atomic<bool> DB_WORKER_CORE::abandoned { false }

Definition at line 140 of file db_worker_thread.cpp.

Referenced by abandon(), and Main().

◆ busy

bool DB_WORKER_CORE::busy = false

Definition at line 136 of file db_worker_thread.cpp.

Referenced by Main().

◆ consumed

size_t DB_WORKER_CORE::consumed = 0

Definition at line 147 of file db_worker_thread.cpp.

◆ cv

std::condition_variable DB_WORKER_CORE::cv

Definition at line 132 of file db_worker_thread.cpp.

Referenced by wake(), and workerWait().

◆ done

bool DB_WORKER_CORE::done = false

Definition at line 137 of file db_worker_thread.cpp.

Referenced by Main().

◆ error

std::exception_ptr DB_WORKER_CORE::error

Definition at line 148 of file db_worker_thread.cpp.

Referenced by Main().

◆ exited

bool DB_WORKER_CORE::exited = false

Set once the exit hook has returned.

Definition at line 142 of file db_worker_thread.cpp.

Referenced by Main().

◆ hasJob

bool DB_WORKER_CORE::hasJob = false

Definition at line 135 of file db_worker_thread.cpp.

Referenced by Main().

◆ initFailed

std::atomic<bool> DB_WORKER_CORE::initFailed { false }

Definition at line 139 of file db_worker_thread.cpp.

Referenced by Main().

◆ job

std::function<void( DB_JOB_CONTEXT& )> DB_WORKER_CORE::job

Definition at line 134 of file db_worker_thread.cpp.

Referenced by Main().

◆ key

std::string DB_WORKER_CORE::key

Definition at line 130 of file db_worker_thread.cpp.

Referenced by abandon(), Main(), and releaseSlot().

◆ m

std::mutex DB_WORKER_CORE::m

Definition at line 131 of file db_worker_thread.cpp.

Referenced by abandon(), and Main().

◆ pumpMessages

bool DB_WORKER_CORE::pumpMessages = false

Windows only, the worker dispatches window messages whenever it waits.

Definition at line 150 of file db_worker_thread.cpp.

Referenced by wake(), and workerWait().

◆ pushed

size_t DB_WORKER_CORE::pushed = 0

Definition at line 146 of file db_worker_thread.cpp.

◆ queue

std::deque<BATCH> DB_WORKER_CORE::queue

Definition at line 145 of file db_worker_thread.cpp.

◆ rejected

std::atomic<bool> DB_WORKER_CORE::rejected { false }

Definition at line 141 of file db_worker_thread.cpp.

◆ slotHeld

bool DB_WORKER_CORE::slotHeld = false

Definition at line 144 of file db_worker_thread.cpp.

Referenced by releaseSlot().

◆ stop

bool DB_WORKER_CORE::stop = false

Definition at line 138 of file db_worker_thread.cpp.

Referenced by Main().


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