DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Defines data for a thread belonging to a RunnableObject
instance. This data is only accessed by the RunnableObject instance's thread. So, no synchronization mechanism is needed. Furthermore, this class is designed to exist only on the stack. RunnableInstance
instances are to be passed as a parameter to the respective thread functions. This ensures that a RunnableInstance
instances is deleted when its thread function returns. This class is responsible for locking an object link (list) parameter (ParamsBase::Param< ObjectLink< ObjectT > > or ParamsBase::ListParam< ObjectLink< ObjectT > >) hold by a class derived (indirectly) from class ParamsBase
and for storing the locked resource in a LinkedObjectWrapper
instance. In turn, the created LinkedObjectWrapper
instance is stored in a LinkedObjectWrapperContainer
instance hold by a class derived (indirectly) from InstrumentDataBase
or from ModuleDataBase
. Furthermore, this class is responsible for unlocking LinkedObjectWrapper
instances it created. Unlocking is triggered either on request or on destruction of the RunnableInstance
instance owning the LinkedObjectWrapper
instance.
More...
Public Member Functions | |
const auto & | GetOwner () const noexcept |
Returns Owner. More... | |
template<typename ObjectT > | |
void | TryLockObject (const ParamsBase::Param< ObjectLink< ObjectT >> &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault) |
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< ObjectT > > and makes the LinkedObjectWrapperContainer ObjectWrapperContainer point to the locked resource. More... | |
template<typename ObjectT > | |
void | LockObject (const ParamsBase::Param< ObjectLink< ObjectT >> &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault) |
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< ObjectT > > and makes the LinkedObjectWrapperContainer ObjectWrapperContainer point to the locked resource. More... | |
template<typename ObjectT > | |
void | UnlockObject (LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer) |
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer . The LinkedObjectWrapperPointer contained in ObjectWrapperContainer is invalidated (set to nullptr)! More... | |
template<typename ObjectT > | |
void | LockObject (const ParamsBase::ListParam< ObjectLink< ObjectT >> &LinkListParam, LinkedObjectWrapperContainerList< ObjectT > &ObjectWrapperContainerList, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault) |
Locks Object instances referenced by a list parameter LinkListParam of type ParamsBase::ListParam< ObjectLink< ObjectT > > and creates containers in LinkedObjectWrapperContainerList ObjectWrapperContainerList which point to the locked resources. More... | |
template<typename ObjectT > | |
void | UnlockObject (LinkedObjectWrapperContainerList< ObjectT > &ObjectWrapperContainerList) |
Unlocks Object instances stored in the LinkedObjectWrapperContainerList ObjectWrapperContainerList . More... | |
bool | CareAboutWrappers () |
Unregisters owned LinkedObjectWrapper instances from their destiny resources in case of the respective destiny resource not being in a ready state (e.g. a stopped/error state). Registers again after the respective destiny resource has returned to a ready state. More... | |
std::string | GetNotReadyObjectNamesString () const |
Finds all linked Object instances Owner makes use of which are not in a ready state and builds a string identifying all these Object instances. More... | |
Public Member Functions inherited from Util::INonCopyable | |
INonCopyable (const INonCopyable &)=delete | |
INonCopyable & | operator= (const INonCopyable &)=delete |
Public Attributes | |
const Object::ParamsGetterType | ParamsGetter |
Invoke to obtain the parameters (derived from ParamsBase ) of Owner. More... | |
Protected Member Functions | |
RunnableInstance (RunnableObject &Owner, std::promise< void > &&ThreadExitedPromise) | |
Constructs a non-empty RunnableInstance instance. More... | |
RunnableInstance (RunnableInstance &&Other) | |
Move-constructs a RunnableInstance instance. Other becomes empty. Not noexcept since LinkedObjectWrapperBase::ListType (std::list ) move constructor might throw. More... | |
~RunnableInstance () | |
Protected Member Functions inherited from Util::INonCopyable | |
constexpr | INonCopyable ()=default |
~INonCopyable ()=default | |
Private Member Functions | |
void | SetThreadExited () |
Signals that Owner's thread has exited. Refer to RunnableObject::OnThreadHasExited(). More... | |
template<typename ObjectT > | |
decltype(auto) | StoreLockedObject (std::unique_ptr< LinkedObjectWrapper< ObjectT >> &&ObjectWrapperPtr, LinkedObjectWrapperContainerBase &ObjectWrapperContainer) |
Stores a newly created LinkedObjectWrapper instance in OwnedLinkedObjectWrappers. More... | |
Private Attributes | |
const RunnableObject & | Owner |
RunnableObject instance which operates on this RunnableInstance (by its thread). The RunnableObject instance's tasks/events might access the object itself via GetOwner() . More... | |
std::promise< void > | ThreadExitedPromise |
Signals the RunnableObject instance owning the thread that its thread has terminated. This is signaled on destruction of this RunnableInstance instance. Refer to RunnableObject::ThreadExitedSignal and to RunnableObject::OnThreadHasExited(). More... | |
bool | Empty = false |
Set to true if it was moved from this instance to indicate that ThreadExitedPromise has no shared state anymore. More... | |
LinkedObjectWrapperBase::ListType | OwnedLinkedObjectWrappers |
List of all LinkedObjectWrapper instances owned by this RunnableInstance instance (thus belonging to a RunnableObject instance). If the RunnableInstance's parent RunnableObject is terminated, by deleting the corresponding RunnableInstance , all these LinkedObjectWrapper instances are also deleted to unlock their linked resources. More... | |
Defines data for a thread belonging to a RunnableObject
instance. This data is only accessed by the RunnableObject instance's thread. So, no synchronization mechanism is needed. Furthermore, this class is designed to exist only on the stack. RunnableInstance
instances are to be passed as a parameter to the respective thread functions. This ensures that a RunnableInstance
instances is deleted when its thread function returns. This class is responsible for locking an object link (list) parameter (ParamsBase::Param< ObjectLink< ObjectT > > or ParamsBase::ListParam< ObjectLink< ObjectT > >) hold by a class derived (indirectly) from class ParamsBase
and for storing the locked resource in a LinkedObjectWrapper
instance. In turn, the created LinkedObjectWrapper
instance is stored in a LinkedObjectWrapperContainer
instance hold by a class derived (indirectly) from InstrumentDataBase
or from ModuleDataBase
. Furthermore, this class is responsible for unlocking LinkedObjectWrapper
instances it created. Unlocking is triggered either on request or on destruction of the RunnableInstance
instance owning the LinkedObjectWrapper
instance.
|
protected |
Constructs a non-empty RunnableInstance
instance.
Owner | Refer to Owner. |
ThreadExitedPromise | Refer to ThreadExitedPromise. |
Definition at line 753 of file Object.cpp.
|
protected |
Move-constructs a RunnableInstance
instance. Other
becomes empty. Not noexcept since LinkedObjectWrapperBase::ListType (std::list
) move constructor might throw.
Other | RunnableInstance instance to move from |
Definition at line 760 of file Object.cpp.
|
protected |
Definition at line 767 of file Object.cpp.
bool DynExp::RunnableInstance::CareAboutWrappers | ( | ) |
Unregisters owned LinkedObjectWrapper
instances from their destiny resources in case of the respective destiny resource not being in a ready state (e.g. a stopped/error state). Registers again after the respective destiny resource has returned to a ready state.
LinkedObjectWrapper
instance is in a ready state. Returns false if any destiny resource is in an error state. Definition at line 776 of file Object.cpp.
std::string DynExp::RunnableInstance::GetNotReadyObjectNamesString | ( | ) | const |
Finds all linked Object
instances Owner makes use of which are not in a ready state and builds a string identifying all these Object
instances.
Definition at line 815 of file Object.cpp.
|
inlinenoexcept |
|
inline |
Locks Object
instances referenced by a list parameter LinkListParam
of type ParamsBase::ListParam< ObjectLink< ObjectT > > and creates containers in LinkedObjectWrapperContainerList
ObjectWrapperContainerList
which point to the locked resources.
ObjectT | Type of the (multiple) managed Object |
LinkListParam | Object link list parameter describing the destiny resources to lock |
ObjectWrapperContainerList | LinkedObjectWrapperContainerList to store references to the locked resources |
Timeout | Timeout to be passed to ObjectLink::LockObject |
Util::EmptyException | is thrown if LinkListParam is empty and non-optional. |
|
inline |
Locks an Object
instance referenced by a parameter LinkParam
of type ParamsBase::Param< ObjectLink< ObjectT > > and makes the LinkedObjectWrapperContainer
ObjectWrapperContainer
point to the locked resource.
Throwing version of TryLockObject()
. Refer to ObjectLink::LockObject.
ObjectT | Type of the managed Object |
LinkParam | Object link parameter describing the destiny resource to lock |
ObjectWrapperContainer | LinkedObjectWrapperContainer to store a reference to the locked resource |
Timeout | Timeout to be passed to ObjectLink::LockObject |
|
private |
Signals that Owner's thread has exited. Refer to RunnableObject::OnThreadHasExited().
Definition at line 825 of file Object.cpp.
|
inlineprivate |
Stores a newly created LinkedObjectWrapper
instance in OwnedLinkedObjectWrappers.
ObjectT | Type of the managed Object |
ObjectWrapperPtr | Pointer to the newly created LinkedObjectWrapper instance to take ownership of |
ObjectWrapperContainer | Reference to the ObjectWrapperContainer referencing the newly created LinkedObjectWrapper instance |
LinkedObjectWrapper
instance
|
inline |
Locks an Object
instance referenced by a parameter LinkParam
of type ParamsBase::Param< ObjectLink< ObjectT > > and makes the LinkedObjectWrapperContainer
ObjectWrapperContainer
point to the locked resource.
ObjectT | Type of the managed Object |
LinkParam | Object link parameter describing the destiny resource to lock |
ObjectWrapperContainer | LinkedObjectWrapperContainer to store a reference to the locked resource |
Timeout | Timeout to be passed to ObjectLink::TryLockObject |
|
inline |
Unlocks an Object
instance stored in the LinkedObjectWrapperContainer
ObjectWrapperContainer
. The LinkedObjectWrapperPointer
contained in ObjectWrapperContainer
is invalidated (set to nullptr)!
ObjectT | Type of the managed Object |
ObjectWrapperContainer | LinkedObjectWrapperContainer holding a reference to the locked resource |
|
inline |
Unlocks Object
instances stored in the LinkedObjectWrapperContainerList
ObjectWrapperContainerList
.
ObjectT | Type of the (multiple) managed Object |
ObjectWrapperContainerList | LinkedObjectWrapperContainerList holding references to the locked resources |
|
private |
Set to true if it was moved from this instance to indicate that ThreadExitedPromise has no shared state anymore.
|
private |
List of all LinkedObjectWrapper
instances owned by this RunnableInstance
instance (thus belonging to a RunnableObject
instance). If the RunnableInstance's
parent RunnableObject
is terminated, by deleting the corresponding RunnableInstance
, all these LinkedObjectWrapper
instances are also deleted to unlock their linked resources.
|
private |
RunnableObject
instance which operates on this RunnableInstance
(by its thread). The RunnableObject
instance's tasks/events might access the object itself via GetOwner()
.
const Object::ParamsGetterType DynExp::RunnableInstance::ParamsGetter |
Invoke to obtain the parameters (derived from ParamsBase
) of Owner.
|
private |
Signals the RunnableObject
instance owning the thread that its thread has terminated. This is signaled on destruction of this RunnableInstance
instance. Refer to RunnableObject::ThreadExitedSignal and to RunnableObject::OnThreadHasExited().