Changeset 387a84 for src/UIElements


Ignore:
Timestamp:
Feb 14, 2016, 12:34:28 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
e7ed12
Parents:
5aec20
git-author:
Frederik Heber <heber@…> (01/05/16 22:26:38)
git-committer:
Frederik Heber <heber@…> (02/14/16 12:34:28)
Message:

FIX: Added mutex to ObservedValuesContainer to ensure atomic access.

Location:
src/UIElements/Qt4/InstanceBoard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp

    r5aec20 r387a84  
    216216  const onDestroy_t onDestroy;
    217217
     218  //!> internal mutex to have atomic access to control maps
     219  mutable boost::recursive_mutex atomic_mutex;
     220
    218221private:
    219222  /** Internal function to check whether an Observed instance identified by
  • src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp

    r5aec20 r387a84  
    1818
    1919#include "CodePatterns/Assert.hpp"
     20
     21#include <boost/thread/recursive_mutex.hpp>
    2022
    2123template <class T, typename id>
     
    3234ObservedValuesContainer<T,id>::~ObservedValuesContainer()
    3335{
     36  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    3437  for (typename CountedObservedValues_t::iterator iter = ObservedValues.begin();
    3538      iter != ObservedValues.end(); ++iter) {
     
    4750typename T::ptr ObservedValuesContainer<T,id>::get(const id _id)
    4851{
     52  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    4953  LOG(3, "DEBUG: ObservedValuesContainer got get() for an observed value of "
    5054      << NameOfType << " " << _id);
     
    6064    const id _id)
    6165{
     66  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    6267  LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsConnected() for an observed value of "
    6368      << NameOfType << " " << _id);
     
    7378    const id _id) const
    7479{
     80  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    7581  typename CountedObservedValues_t::const_iterator iter = ObservedValues.find(_id);
    7682  return ((iter != ObservedValues.end()) && (iter->second.getEraseCandidate().second == 0));
     
    8187    const id _id)
    8288{
     89  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    8390  LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsDisconnected() for an observed value of "
    8491      << NameOfType << " " << _id);
     
    100107    const id _id) const
    101108{
     109  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    102110  typename subjectKilledCount_t::const_iterator iter = subjectKilledCount.find(_id);
    103111  return ((iter != subjectKilledCount.end()) && (iter->second == T::MAX_ObservedTypes));
     
    107115void ObservedValuesContainer<T,id>::countsubjectKilled(const id _id)
    108116{
     117  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    109118  LOG(3, "DEBUG: ObservedValuesContainer got subjectKilled() for an observed value of "
    110119      << NameOfType << " " << _id);
     
    127136void ObservedValuesContainer<T,id>::removeObservedValues(const id _id)
    128137{
     138  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    129139  LOG(3, "DEBUG: ObservedValuesContainer removes " << NameOfType << " " << _id);
    130140  // call callback function
     
    141151void ObservedValuesContainer<T,id>::eraseObservedValues(const id _id)
    142152{
     153  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    143154#ifndef NDEBUG
    144155  std::pair< typename std::set<id>::iterator, bool > inserter =
     
    156167bool ObservedValuesContainer<T,id>::checkMarkedForErase(const id _id) const
    157168{
     169  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    158170  return MarkedForErase.count(_id);
    159171}
     
    162174void ObservedValuesContainer<T,id>::insert(const id _id, const typename T::ptr &_obsvalues)
    163175{
     176  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    164177  typename ObservedValuesContainer<T,id>::RefCountedObserved::Value_t value(std::make_pair(_obsvalues,0));
    165178  typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
     
    184197bool ObservedValuesContainer<T,id>::changeIdentifier(const id _oldid, const id _newid)
    185198{
     199  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    186200  const typename CountedObservedValues_t::iterator Colditer = ObservedValues.find(_oldid);
    187201  const typename CountedObservedValues_t::iterator Cnewiter = ObservedValues.find(_newid);
     
    222236bool ObservedValuesContainer<T,id>::isPresent(const id _id) const
    223237{
     238  boost::recursive_mutex::scoped_lock lock(atomic_mutex);
    224239  typename CountedObservedValues_t::const_iterator iter = ObservedValues.find(_id);
    225240  return (iter != ObservedValues.end());
Note: See TracChangeset for help on using the changeset viewer.