Data structure to contain data which is synchronized in between different threads. This is needed since the instrument thread, the threads of different modules, as well as the main thread might access the instrument at the same time. Every class (indirectly) derived from class InstrumentBase
must be accompanied by a instrument data class derived from InstrumentDataBase
. InstrumentDataBase
and derived classes contain data shared by the respective instrument, module and main threads. Data only used by the instrument itself should be private members of the instrument class.
More...
#include <Instrument.h>
|
using | TaskQueueType = std::list< std::unique_ptr< TaskBase > > |
| Type of an instrument task queue owning the tasks within.
|
|
using | TaskQueueIteratorType = TaskQueueType::const_iterator |
| Const iterator type to elements of TaskQueueType .
|
|
Data structure to contain data which is synchronized in between different threads. This is needed since the instrument thread, the threads of different modules, as well as the main thread might access the instrument at the same time. Every class (indirectly) derived from class InstrumentBase
must be accompanied by a instrument data class derived from InstrumentDataBase
. InstrumentDataBase
and derived classes contain data shared by the respective instrument, module and main threads. Data only used by the instrument itself should be private members of the instrument class.
- Warning
- For the same
Object
, always lock the mutex of the corresponding parameter class before the mutex of the corresponding data class (or only one of them).
Definition at line 134 of file Instrument.h.
◆ DynExp::InstrumentDataBase::dispatch_tag
struct DynExp::InstrumentDataBase::dispatch_tag |
◆ TaskQueueIteratorType
Const iterator type to elements of TaskQueueType
.
Definition at line 138 of file Instrument.h.
◆ TaskQueueType
Type of an instrument task queue owning the tasks within.
Definition at line 137 of file Instrument.h.
◆ InstrumentDataBase()
DynExp::InstrumentDataBase::InstrumentDataBase |
( |
| ) |
|
|
inline |
◆ ~InstrumentDataBase()
virtual DynExp::InstrumentDataBase::~InstrumentDataBase |
( |
| ) |
|
|
inlinevirtual |
◆ CheckError()
void DynExp::InstrumentDataBase::CheckError |
( |
| ) |
const |
|
private |
◆ CheckQueueState()
void DynExp::InstrumentDataBase::CheckQueueState |
( |
bool |
CallFromInstrThread | ) |
const |
|
private |
Checks whether it is currently allowed to enqueue tasks into the instrument task queue.
- Parameters
-
CallFromInstrThread | Pass true if the instrument itself enqueues a task. |
- Exceptions
-
Definition at line 194 of file Instrument.cpp.
◆ CloseQueue()
void DynExp::InstrumentDataBase::CloseQueue |
( |
| ) |
|
|
inlineprivate |
◆ EnqueuePriorityTask() [1/2]
void DynExp::InstrumentDataBase::EnqueuePriorityTask |
( |
std::unique_ptr< TaskBase > && |
Task | ) |
|
|
inline |
Enqueues a task at the front of an instrument's task queue and notifies the instrument about the new task.
- Parameters
-
Task | Task to enqueue, the queue takes ownership of the task. |
Definition at line 220 of file Instrument.h.
◆ EnqueuePriorityTask() [2/2]
void DynExp::InstrumentDataBase::EnqueuePriorityTask |
( |
std::unique_ptr< TaskBase > && |
Task, |
|
|
bool |
CallFromInstrThread, |
|
|
bool |
NotifyReceiver |
|
) |
| |
|
private |
Enqueues a task at the front of an instrument's task queue and notifies the instrument about the new task.
- Parameters
-
Task | Task to enqueue, the queue takes ownership of the task. |
CallFromInstrThread | Pass true if the instrument itself enqueues a task. This argument is forwarded to CheckQueueState() . |
NotifyReceiver | Determines whether the instrument thread is notified that a new task has been enqueued. This is e.g. not desired when enqueuing update tasks in InstrumentBase::UpdateData(). |
Definition at line 147 of file Instrument.cpp.
◆ EnqueueTask() [1/2]
void DynExp::InstrumentDataBase::EnqueueTask |
( |
std::unique_ptr< TaskBase > && |
Task | ) |
|
|
inline |
Enqueues a task at the back of an instrument's task queue and notifies the instrument about the new task.
- Parameters
-
Task | Task to enqueue, the queue takes ownership of the task. |
Definition at line 213 of file Instrument.h.
◆ EnqueueTask() [2/2]
void DynExp::InstrumentDataBase::EnqueueTask |
( |
std::unique_ptr< TaskBase > && |
Task, |
|
|
bool |
CallFromInstrThread, |
|
|
bool |
NotifyReceiver |
|
) |
| |
|
private |
Enqueues a task at the back of an instrument's task queue and notifies the instrument about the new task.
- Parameters
-
Task | Task to enqueue, the queue takes ownership of the task. |
CallFromInstrThread | Pass true if the instrument itself enqueues a task. This argument is forwarded to CheckQueueState() . |
NotifyReceiver | Determines whether the instrument thread is notified that a new task has been enqueued. This is e.g. not desired when enqueuing update tasks in InstrumentBase::UpdateData(). |
Definition at line 137 of file Instrument.cpp.
◆ GetException()
auto DynExp::InstrumentDataBase::GetException |
( |
| ) |
const |
|
inlinenoexcept |
◆ GetLastUpdateTime()
auto DynExp::InstrumentDataBase::GetLastUpdateTime |
( |
| ) |
const |
|
inline |
Getter for LastUpdate.
- Returns
- Returns the time point when the instrument issued a task to update its data last.
Definition at line 283 of file Instrument.h.
◆ GetNewTaskNotifier()
◆ GetNumEnqueuedTasks()
size_t DynExp::InstrumentDataBase::GetNumEnqueuedTasks |
( |
| ) |
const |
|
inlinenoexcept |
Getter for the instrument task queue's length.
- Returns
- Returns the number of enqueued tasks.
Definition at line 256 of file Instrument.h.
◆ GetNumFinishedTasks()
size_t DynExp::InstrumentDataBase::GetNumFinishedTasks |
( |
| ) |
const |
|
inlinenoexcept |
Getter for the length of the instrument's list of finished tasks.
- Returns
- Returns the number of finished tasks.
Definition at line 270 of file Instrument.h.
◆ GetTaskBack()
auto DynExp::InstrumentDataBase::GetTaskBack |
( |
| ) |
|
|
inlinenoexcept |
Getter for last enqueued task.
- Returns
- Returns an iterator to the instrument task queue's end.
Definition at line 250 of file Instrument.h.
◆ GetTaskFront()
auto DynExp::InstrumentDataBase::GetTaskFront |
( |
| ) |
|
|
inlinenoexcept |
Getter for first enqueued task.
- Returns
- Returns an iterator to the instrument task queue's beginning.
Definition at line 244 of file Instrument.h.
◆ IsQueueClosed()
bool DynExp::InstrumentDataBase::IsQueueClosed |
( |
| ) |
const |
|
inlinenoexcept |
◆ PopFinishedTask()
std::unique_ptr< TaskBase > DynExp::InstrumentDataBase::PopFinishedTask |
( |
| ) |
|
Removes a task from the front of an instrument's list of finished tasks.
- Returns
- Returns the task releasing ownership of it. Returns nullptr if the list is empty.
Definition at line 126 of file Instrument.cpp.
◆ PopTaskBack()
std::unique_ptr< TaskBase > DynExp::InstrumentDataBase::PopTaskBack |
( |
| ) |
|
Removes a task from the back of an instrument's task queue.
- Returns
- Returns the task releasing ownership of it. Returns nullptr if the queue is empty.
- Exceptions
-
Definition at line 112 of file Instrument.cpp.
◆ PopTaskFront()
std::unique_ptr< TaskBase > DynExp::InstrumentDataBase::PopTaskFront |
( |
| ) |
|
Removes a task from the front of an instrument's task queue.
- Returns
- Returns the task releasing ownership of it. Returns nullptr if the queue is empty.
- Exceptions
-
Definition at line 98 of file Instrument.cpp.
◆ RemoveAllTasks()
void DynExp::InstrumentDataBase::RemoveAllTasks |
( |
| ) |
|
|
private |
◆ RemoveAllTasksExceptFront()
void DynExp::InstrumentDataBase::RemoveAllTasksExceptFront |
( |
| ) |
|
|
private |
Clears the instrument's task queue but keeps the front task (the task with highest priority which is handled next).
Definition at line 170 of file Instrument.cpp.
◆ RemoveTaskFromQueue()
Removes a task from the instrument's task queue and inserts it into the instrument's list of finished tasks if TaskBase::KeepFinishedTask() returns true.
- Parameters
-
Task | Iterator to an enqueued task. |
Definition at line 157 of file Instrument.cpp.
◆ Reset()
void DynExp::InstrumentDataBase::Reset |
( |
| ) |
|
|
private |
◆ ResetImpl()
◆ FinishedTasks
List of the instrument's finished tasks. Tasks are moved here from TaskQueue after completion.
Definition at line 377 of file Instrument.h.
◆ InstrumentBaseOnly
◆ InstrumentException
std::exception_ptr DynExp::InstrumentDataBase::InstrumentException |
|
private |
Used to transfer exceptions from the instrument thread to the main thread. Stores the exception responsible for the error state if the instrument which owns the respective InstrumentDataBase's
instance is in such an error state.
Definition at line 394 of file Instrument.h.
◆ InstrumentThreadOnly
◆ LastUpdate
std::chrono::system_clock::time_point DynExp::InstrumentDataBase::LastUpdate |
|
private |
◆ NewTaskNotifier
Used to notify the instrument thread about new tasks when enqueuing tasks into the task queue. This allows the instrument thread to sleep until new tasks have to be handled.
Definition at line 385 of file Instrument.h.
◆ QueueClosed
bool DynExp::InstrumentDataBase::QueueClosed |
|
private |
If set to true, no new tasks can be enqueued (useful if an instrument is e.g. stopped).
Definition at line 378 of file Instrument.h.
◆ TaskQueue
The documentation for this class was generated from the following files: