Ignore:
Timestamp:
Jul 25, 2015, 1:02:12 PM (10 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:
9a4880
Parents:
9ec4b8
git-author:
Frederik Heber <heber@…> (06/18/15 00:56:26)
git-committer:
Frederik Heber <heber@…> (07/25/15 13:02:12)
Message:

FIX: ActionQueue::isIdle() states whether actions are executed or not.

  • QtUIFactory uses this to wait till test running next action.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.cpp

    r9ec4b8 ra87d1e2  
    6363    history(new ActionHistory),
    6464    lastActionOk(true),
    65 #ifdef HAVE_ACTION_THREAD
    6665    CurrentAction(0),
     66#ifdef HAVE_ACTION_THREAD
    6767    run_thread(boost::bind(&ActionQueue::run, this)),
    6868    run_thread_isIdle(true),
     
    108108#ifndef HAVE_ACTION_THREAD
    109109  try {
    110     if (!isDryRun(newaction))
     110    if (!isDryRun(newaction)) {
     111      CurrentAction = actionqueue.size()-1;
    111112      newaction->call();
     113      CurrentAction = actionqueue.size();
     114    }
    112115    lastActionOk = true;
    113116  } catch(ActionFailureException &e) {
     
    130133  }
    131134#else
    132   setRunThreadIdle(CurrentAction == actionqueue.size());
    133135  mtx_queue.unlock();
     136  setRunThreadIdle(isIdle());
    134137#endif
    135138}
     
    144147  mtx_queue.lock();
    145148  tempqueue.push_back( newaction );
    146   setRunThreadIdle( !((CurrentAction != actionqueue.size()) || !tempqueue.empty()) );
     149  const bool tempqueue_notempty = !tempqueue.empty();
    147150  mtx_queue.unlock();
    148 #endif
     151  setRunThreadIdle( !((!isIdle()) || tempqueue_notempty) );
     152#endif
     153}
     154
     155bool ActionQueue::isIdle() const
     156{
     157#ifdef HAVE_ACTION_THREAD
     158  boost::unique_lock<boost::mutex> lock(mtx_queue);
     159#endif
     160  bool status = (CurrentAction == actionqueue.size());
     161  return status;
    149162}
    150163
     
    169182    mtx_queue.lock();
    170183    insertTempQueue();
    171     bool status = (CurrentAction != actionqueue.size());
    172184    mtx_queue.unlock();
     185    bool status = !isIdle();
    173186    while (status) {
    174187      //      boost::this_thread::disable_interruption di;
     
    208221      // while an action instance is "in-use"
    209222      insertTempQueue();
    210       status = (CurrentAction != actionqueue.size());
    211223      mtx_queue.unlock();
     224      status = !isIdle();
    212225    }
    213     setRunThreadIdle( !((CurrentAction != actionqueue.size()) || !tempqueue.empty()) );
     226    mtx_queue.lock();
     227    const bool tempqueue_notempty = !tempqueue.empty();
     228    mtx_queue.unlock();
     229    setRunThreadIdle( !((!isIdle()) || tempqueue_notempty) );
    214230    cond_idle.notify_one();
    215231//    LOG(1, "DEBUG: End of ActionQueue's run() loop.");
Note: See TracChangeset for help on using the changeset viewer.