Changeset 74459a


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 ...)
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r415ddd r74459a  
    4040AM_CONDITIONAL([CONDPYTHON], [test x"$enable_python" != x"no"])
    4141AC_SUBST(HAVE_PYTHON)
     42
     43dnl Check whether no extra thread for ActionQueue shall be used
     44AC_MSG_CHECKING(whether to enable ActionQueue's run thread)
     45AC_ARG_ENABLE(
     46        [action_thread],
     47        AS_HELP_STRING([--enable-action-thread],[turn on extra run thread for ActionQueue [default=yes]]),
     48        enable_action_thread=$enableval,
     49        enable_action_thread="no"
     50)
     51AC_MSG_RESULT($enable_action_thread)
     52AS_IF([test x"$enable_action_thread" != x"no"],[
     53  AC_DEFINE(HAVE_ACTION_THREAD,1, ["Have extra run thread for ActionQueue."])
     54])
     55AM_CONDITIONAL([CONDACTIONTHREAD], [test x"$enable_action_thread" != x"no"])
     56AC_SUBST(HAVE_ACTION_THREAD)
    4257
    4358dnl Check if we have enable qtgui
  • 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
  • src/Python/wait.cpp

    r415ddd r74459a  
    4545{
    4646  // prevent wait() in python scripts in case of present UI (loaded sessions)
     47#ifdef HAVE_ACTION_THREAD
    4748  if (!UIFactory::isFactoryPresent()) {
    4849    LOG(0, "Waiting for action queue to idle.");
    4950    waitQueue();
    5051  }
     52#endif
    5153}
  • src/builder.cpp

    r415ddd r74459a  
    4949  doUI();
    5050
     51#ifdef HAVE_ACTION_THREAD
    5152  waitQueue();
    5253  stopQueue();
     54#endif
    5355  if (UIFactory::getInstance().getUIName() == "CommandLine")
    5456    return saveAll();
  • src/cleanUp.cpp

    r415ddd r74459a  
    114114void stopAndPurgeQueue()
    115115{
     116#ifdef HAVE_ACTION_THREAD
    116117  // adding a wait here such that ActionQueue's run_thread is done any may stop
    117118  waitQueue();
     119#endif
    118120  MoleCuilder::ActionQueue::purgeInstance();
    119121  MoleCuilder::OptionRegistry::purgeInstance();
     
    218220}
    219221
     222#ifdef HAVE_ACTION_THREAD
    220223/** Stops the queue such that all Actions are done.
    221224 *
     
    233236  MoleCuilder::ActionQueue::getInstance().wait();
    234237}
     238#endif
  • src/cleanUp.hpp

    r415ddd r74459a  
    1919void purgeStaticInstances();
    2020int saveAll();
     21#ifdef HAVE_ACTION_THREAD
    2122void stopQueue();
    2223void waitQueue();
     24#endif
    2325
    2426#endif /* CLEANUP_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.