Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitk::DataStorageAccessRule Class Reference

The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified concurrently. The idea and its restrictions is explained in the sections and diagrams below. More...

#include <mitkDataStorageAccessRule.h>

Inheritance diagram for mitk::DataStorageAccessRule:
Collaboration diagram for mitk::DataStorageAccessRule:

Public Types

enum  RuleType { ADD_RULE, REMOVE_RULE }
 
- Public Types inherited from berry::Object
typedef Object Self
 
typedef berry::SmartPointer< SelfPointer
 
typedef berry::SmartPointer< const SelfConstPointer
 
typedef berry::WeakPointer< SelfWeakPtr
 
typedef berry::WeakPointer< const SelfConstWeakPtr
 

Public Member Functions

 berryObjectMacro (DataStorageAccessRule)
 
 DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, DataStorageAccessRule::RuleType myRule)
 
bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) const override
 
bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) const override
 
- Public Member Functions inherited from berry::ISchedulingRule
 berryObjectMacro (berry::ISchedulingRule)
 
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
 
virtual Reflection::TypeInfo GetTypeInfo () const
 
virtual QList< Reflection::TypeInfoGetSuperclasses () const
 
virtual void Delete ()
 
QDebug Print (QDebug os, Indent Indent=0) const
 
virtual QString ToString () const
 
virtual uint HashCode () const
 
virtual bool operator< (const Object *) const
 
void Register () const
 
void UnRegister (bool del=true) const
 
int GetReferenceCount () const
 
void SetReferenceCount (int)
 
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
virtual bool operator== (const Object *) const
 

Public Attributes

RuleType m_Rule
 

Additional Inherited Members

- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
 
static Reflection::TypeInfo GetStaticTypeInfo ()
 
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
 
- Protected Member Functions inherited from berry::Object
 Object ()
 
virtual ~Object ()
 
virtual QDebug PrintSelf (QDebug os, Indent indent) const
 
virtual QDebug PrintHeader (QDebug os, Indent indent) const
 
virtual QDebug PrintTrailer (QDebug os, Indent indent) const
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Detailed Description

The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified concurrently. The idea and its restrictions is explained in the sections and diagrams below.

the IsScheduling(...) method :

returns true or false depending if conflictions with another rule are found

the rule behavior if jobs holing add rules of an DataTree node

two add rules are always allowed since there are no conflictions when adding nodes concurrently. The final order the nodes are finally added has to be checked by the programmer of the particular job

the rule behavior when two jobs holding remove rules of a DataNode

two jobs holding remove rules can be executed concurrently since all removing scenarios do not cause conflictions. If two jobs are trying to remove the same DataTree node the job by itself needs to check if the node is still available before executing the removing command

the rule behavior of a jobs that is holding an add rule compared with a job that is holding a remove rule on a DataNode

adding and removing of DataTree nodes concurrently can cause serious errors and needs to be restricted. Performing add and remove operations on different DataStorage branches can be done concurrently since no conflictions are expected. the performing of add and remove operation on the same DataNode, its parent nodes or child nodes of the same branch by different jobs is not allowed. Jobs holding rules that are trying to perform such operations are blocked until the running job is done.

the Contains method (...) method :

only necessary for a specific type of scheduling rules. Has to be used if IScheduling rules are composed into hierarchies. In such scenarios the contains(...) method specifies the hierarchical relationships among the locks. For example if a method tries to acquire a specific * rule to lock a specific directory it needs to check if no job is holding a rule for one or more subdirectories. For all cases in which no composing of IScheduling rules is needed the Contains(...) method only needs to check if two jobs are holding exactly the same IScheduling rule on the same object. Normally this can be achieved by just calling the IsConflicting(...) method.

Author
Jan Woerner

Definition at line 77 of file mitkDataStorageAccessRule.h.

Member Enumeration Documentation

◆ RuleType

Enumerator
ADD_RULE 
REMOVE_RULE 

Definition at line 82 of file mitkDataStorageAccessRule.h.

Constructor & Destructor Documentation

◆ DataStorageAccessRule()

mitk::DataStorageAccessRule::DataStorageAccessRule ( mitk::DataStorage::Pointer  myDataStorage,
mitk::DataNode::Pointer  myDataNode,
DataStorageAccessRule::RuleType  myRule 
)

Member Function Documentation

◆ berryObjectMacro()

mitk::DataStorageAccessRule::berryObjectMacro ( DataStorageAccessRule  )

◆ Contains()

bool mitk::DataStorageAccessRule::Contains ( berry::ISchedulingRule::Pointer  rule) const
overridevirtual

Returns whether this scheduling rule completely contains another scheduling rule. Rules can only be nested within a thread if the inner rule is completely contained within the outer rule.

Implementations of this method must obey the rules of a partial order relation on the set of all scheduling rules. In particular, implementations must be reflexive (a.contains(a) is always true), antisymmetric (a.contains(b) and b.contains(a) iff equals(b), and transitive (if a.contains(b) and b.contains(c), then a.contains(c)). Implementations of this method must return false when compared to a rule they know nothing about.

Parameters
rulethe rule to check for containment
Returns
true if this rule contains the given rule, and false otherwise.

Implements berry::ISchedulingRule.

◆ IsConflicting()

bool mitk::DataStorageAccessRule::IsConflicting ( berry::ISchedulingRule::Pointer  myRule) const
overridevirtual

Returns whether this scheduling rule is compatible with another scheduling rule. If true is returned, then no job with this rule will be run at the same time as a job with the conflicting rule. If false is returned, then the job manager is free to run jobs with these rules at the same time.

Implementations of this method must be reflexive, symmetric, and consistent, and must return false when compared to a rule they know nothing about.

Parameters
myRulethe rule to check for conflicts
Returns
true if the rule is conflicting, and false otherwise.

Implements berry::ISchedulingRule.

Member Data Documentation

◆ m_Rule

RuleType mitk::DataStorageAccessRule::m_Rule

Definition at line 84 of file mitkDataStorageAccessRule.h.


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