Changeset 74459a for src/Actions


Ignore:
Timestamp:
May 20, 2014, 9:14:56 AM (11 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:
caece4
Parents:
415ddd
git-author:
Frederik Heber <heber@…> (02/19/14 19:35:28)
git-committer:
Frederik Heber <heber@…> (05/20/14 09:14:56)
Message:

Added --disable-action-thread to allow disabling of extra run thread.

  • this removes all functionality related to having ActionQueue::run() executed in a distinct thread.
  • the extra thread is currently disabled by default as probably some stuff in QtGUI will be broken (bonds disappearing while being drawn ...)
Location:
src/Actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.cpp

    r415ddd r74459a  
    5858    AR(new ActionRegistry()),
    5959    history(new ActionHistory),
     60#ifndef HAVE_ACTION_THREAD
     61    CurrentAction(0)
     62#else
    6063    CurrentAction(0),
    6164    run_thread(boost::bind(&ActionQueue::run, this)),
    6265    run_thread_isIdle(true)
     66#endif
    6367{}
    6468
    6569ActionQueue::~ActionQueue()
    6670{
     71#ifdef HAVE_ACTION_THREAD
    6772  stop();
     73#endif
    6874
    6975  // free all actions contained in actionqueue
     
    8692  Action *newaction = _action->clone(state);
    8793  newaction->prepare(state);
     94#ifdef HAVE_ACTION_THREAD
    8895  mtx_queue.lock();
     96#endif
    8997  actionqueue.push_back( newaction );
     98#ifndef HAVE_ACTION_THREAD
     99  try {
     100    newaction->call();
     101  } catch(ActionFailureException &e) {
     102    std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl;
     103    World::getInstance().setExitFlag(5);
     104  }
     105#else
    90106  {
    91107    boost::lock_guard<boost::mutex> lock(mtx_idle);
     
    93109  }
    94110  mtx_queue.unlock();
     111#endif
    95112}
    96113
    97114void ActionQueue::insertAction(Action *_action, enum Action::QueryOptions state)
    98115{
     116#ifndef HAVE_ACTION_THREAD
     117  queueAction(_action, state);
     118#else
    99119  Action *newaction = _action->clone(state);
    100120  newaction->prepare(state);
     
    106126  }
    107127  mtx_queue.unlock();
    108 }
    109 
     128#endif
     129}
     130
     131#ifdef HAVE_ACTION_THREAD
    110132void ActionQueue::run()
    111133{
     
    157179  } while (!Interrupted);
    158180}
     181#endif
    159182
    160183void ActionQueue::insertTempQueue()
     
    168191}
    169192
     193#ifdef HAVE_ACTION_THREAD
    170194void ActionQueue::wait()
    171195{
     
    176200  }
    177201}
    178 
     202#endif
     203
     204#ifdef HAVE_ACTION_THREAD
    179205void ActionQueue::stop()
    180206{
     
    184210  run_thread.join();
    185211}
     212#endif
    186213
    187214Action* ActionQueue::getActionByName(const std::string &name)
  • src/Actions/ActionQueue.hpp

    r415ddd r74459a  
    1616#include "CodePatterns/Singleton.hpp"
    1717
     18
     19#ifdef HAVE_ACTION_THREAD
    1820#include <boost/thread.hpp>
     21#endif
    1922#include <vector>
    2023
     
    2225#include "Actions/ActionState.hpp"
    2326
     27#ifdef HAVE_ACTION_THREAD
    2428void stopQueue();
    2529void waitQueue();
     30#endif
    2631
    2732namespace MoleCuilder {
     
    117122  void redoLast();
    118123
     124#ifdef HAVE_ACTION_THREAD
    119125  boost::thread &getRunThread()
    120126  { return run_thread; }
     127#endif
    121128
    122129private:
     
    136143  void clear();
    137144
     145#ifdef HAVE_ACTION_THREAD
    138146  /** Runs the ActionQueue.
    139147   *
     
    154162   */
    155163  void wait();
     164#endif
    156165
    157166  /** Insert an action after CurrentAction.
     
    196205  ActionQueue_t tempqueue;
    197206
     207#ifdef HAVE_ACTION_THREAD
    198208  //!> internal thread to call Actions
    199209  boost::thread run_thread;
     
    210220  //!> internal mutex to synchronize access to run_thread_isIdle
    211221  boost::mutex mtx_idle;
     222#endif
    212223};
    213224
  • src/Actions/MakroAction.cpp

    r415ddd r74459a  
    8989bool MakroAction::removeAction(const std::string &name)
    9090{
    91   actions.removeAction(name);
     91  return actions.removeAction(name);
    9292}
    9393
Note: See TracChangeset for help on using the changeset viewer.