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 218 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 221 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 163 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 214 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 153 of file Instrument.cpp.
◆ GetException()
| std::exception_ptr DynExp::InstrumentDataBase::GetException |
( |
| ) |
const |
|
noexcept |
◆ 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 284 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 257 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 271 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 251 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 245 of file Instrument.h.
◆ IndicateException()
| void DynExp::InstrumentDataBase::IndicateException |
( |
| ) |
|
|
inlineprivatenoexcept |
Indicates to the main thread that an exception has happened in the instrument thread. Only performs atomic operations. Hence, this instrument data instance does not need to be locked for this function call.
Definition at line 376 of file Instrument.h.
◆ IsExceptionIndicated()
| bool DynExp::InstrumentDataBase::IsExceptionIndicated |
( |
| ) |
const |
|
inlinenoexcept |
Getter for HasException. Only performs atomic operations. Hence, this instrument data instance does not need to be locked for this function call.
Definition at line 290 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 134 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 120 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 106 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 186 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 173 of file Instrument.cpp.
◆ Reset()
| void DynExp::InstrumentDataBase::Reset |
( |
| ) |
|
|
private |
◆ ResetImpl()
◆ SetException()
| void DynExp::InstrumentDataBase::SetException |
( |
std::exception_ptr |
Exception | ) |
|
|
privatenoexcept |
◆ FinishedTasks
List of the instrument's finished tasks. Tasks are moved here from TaskQueue after completion.
Definition at line 399 of file Instrument.h.
◆ HasException
| std::atomic<bool> DynExp::InstrumentDataBase::HasException |
|
private |
If set to true, indicates to the main thread that an exception has happened in the instrument thread. In that case, the exception is possibly stored in InstrumentException.
Definition at line 416 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 423 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 407 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 400 of file Instrument.h.
◆ TaskQueue
The documentation for this class was generated from the following files: