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>
Public Types | |
enum | RuleType { ADD_RULE = 0, REMOVE_RULE } |
Public Member Functions | |
bool | IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) |
Public Attributes | |
RuleType | m_Rule |
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.
returns true or false depending if conflictions with another rule are found
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
<a name"RemoveRules">
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
<a name"RemoveAddRules">
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.
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.
Definition at line 81 of file mitkDataStorageAccessRule.h.
bool mitk::DataStorageAccessRule::IsConflicting | ( | berry::ISchedulingRule::Pointer | otherISchedulingRule ) |
Definition at line 69 of file mitkDataStorageAccessRule.cpp.
References berry::SmartPointer< TObjectType >::Cast().
{ // test if the stored dataNode // cast to check if the ISchedulingRule is a DataStorageAccessRule DataStorageAccessRule::Pointer sptr_DataStorageAccessRule = sptr_otherISchedulingRule.Cast<DataStorageAccessRule>(); // checks if the Rule of the type ISchedulingRule is a DataStorageAccessRule if(sptr_DataStorageAccessRule == 0) return false ; // the rule to be compared with is a DataStorageAccessRule else { // testing if both jobs holding each rule do operate on the same DataStorage if not false is returned if( !CompareDataStorages(sptr_DataStorageAccessRule->GetDataStorage()) ) return false ; // checks if to rules to be compared are two add rules if (m_Rule == ADD_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType()) return CompareTwoAddorRemoveRules() ; // checks if to the two rules to be compared are two remove rules if(m_Rule == REMOVE_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType()) return CompareTwoAddorRemoveRules() ; // an add and remove rule needs to be compared else { return CompareAddandRemoveRules(sptr_DataStorageAccessRule) ; } } }
Definition at line 88 of file mitkDataStorageAccessRule.h.