JANA2
C++ framework for multi-threaded data processing
|
Public Types | |
enum class | RunState { Running , Stopping , Stopped , TimedOut , Excepted } |
Designed so that the Worker checks in with the Scheduler on his own terms; i.e. More... | |
enum class | BackoffStrategy { Constant , Linear , Exponential } |
using | duration_t = std::chrono::steady_clock::duration |
Public Member Functions | |
JWorker (JArrowProcessingController *japc, JScheduler *scheduler, unsigned worker_id, unsigned cpu_id, unsigned domain_id, bool pin_to_cpu) | |
JWorker (const JWorker &other)=delete | |
If we copy or move the Worker, the underlying std::thread will be left with a dangling pointer back to this . More... | |
JWorker (JWorker &&other)=delete | |
JWorker & | operator= (const JWorker &other)=delete |
RunState | get_runstate () |
void | start () |
void | request_stop () |
void | wait_for_stop () |
void | declare_timeout () |
This allows someone (aka JArrowProcessingController) to declare that this thread has timed out. More... | |
const JException & | get_exception () const |
void | loop () |
This is what the encapsulated thread is supposed to be doing. | |
void | measure_perf (WorkerSummary &result) |
Summarize what/how this Worker is doing. More... | |
void | set_backoff_tries (unsigned backoff_tries) |
unsigned | get_backoff_tries () const |
BackoffStrategy | get_backoff_strategy () const |
void | set_backoff_strategy (BackoffStrategy backoff_strategy) |
duration_t | get_initial_backoff_time () const |
void | set_initial_backoff_time (duration_t initial_backoff_time) |
duration_t | get_checkin_time () const |
void | set_checkin_time (duration_t checkin_time) |
Public Attributes | |
JLogger | logger |
The logger is made public so that somebody else may set it. | |
|
strong |
Designed so that the Worker checks in with the Scheduler on his own terms; i.e.
nobody will update the worker's assignment externally. This eliminates a whole lot of synchronization since we can assume that the Worker's internal state won't be updated by another thread.
|
delete |
If we copy or move the Worker, the underlying std::thread will be left with a dangling pointer back to this
.
So we forbid copying, assigning, and moving.
void JWorker::declare_timeout | ( | ) |
This allows someone (aka JArrowProcessingController) to declare that this thread has timed out.
This ensures that the underlying thread will be detached rather than joined when it is time to wait_for_stop(). Note: Another option was to non-cooperatively kill the thread, at the risk of resource leaks and data corruption. This is NOT supported by std::thread, because smarter people than me have concluded it is a Bad Idea, so we'd have to use the underlying pthread interface if we decide we REALLY want this feature. It doesn't make a difference in the common case because the program will terminate upon timeout anyhow; it only matters in case we are running JANA from a REPL. My instinct is to leave the offending thread alone so that the user has a chance to attach a debugger to the process.
void JWorker::measure_perf | ( | WorkerSummary & | result | ) |
Summarize what/how this Worker is doing.
This is meant to be called from JProcessingController::measure_perf()