Changeset 12d15a for src/Fragmentation
- Timestamp:
- May 4, 2012, 2:19:06 PM (13 years ago)
- 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:
- b0b64c
- Parents:
- 57876b
- git-author:
- Frederik Heber <heber@…> (10/23/11 21:24:18)
- git-committer:
- Frederik Heber <heber@…> (05/04/12 14:19:06)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/FragmentQueue.cpp
r57876b r12d15a 25 25 26 26 FragmentResult FragmentQueue::NoResult(-1); 27 FragmentResult FragmentQueue::ResultDelivered(-2); 27 FragmentResult FragmentQueue::NoResultQueued(-2); 28 FragmentResult FragmentQueue::ResultDelivered(-3); 28 29 29 30 /** Constructor for class FragmentQueue. … … 39 40 {} 40 41 42 /** Checks whether there are jobs in the queue at all. 43 * \return true - jobs present, false - queue is empty 44 */ 45 bool FragmentQueue::isJobPresent() const 46 { 47 return !jobs.empty(); 48 } 49 41 50 /** Pushes a FragmentJob into the internal queue for delivery to server. 42 51 * … … 51 60 ASSERT(!results.count(job.getId()), 52 61 "FragmentQueue::pushJob() - job id "+toString(job.getId())+" has already been used."); 62 results.insert( std::make_pair(job.getId(), NoResult)); 53 63 jobs.push_back(job); 54 results.insert( std::make_pair(job.getId(), NoResult)); 64 } 65 66 /** Pops top-most FragmentJob from internal queue. 67 * 68 * From here on, we expect a result in FragmentQueue::results. 69 * 70 * \return job topmost job from queue 71 */ 72 FragmentJob FragmentQueue::popJob() 73 { 74 ASSERT(jobs.size(), 75 "FragmentQueue::popJob() - there are no jobs on the queue."); 76 FragmentJob job = jobs.front(); 77 ResultMap::iterator iter = results.find(job.getId()); 78 ASSERT(iter != results.end(), 79 "FragmentQueue::popJob() - for job "+toString(job.getId())+" no result place has been stored."); 80 iter->second = NoResultQueued; 81 jobs.pop_front(); 82 return job; 55 83 } 56 84 … … 65 93 return ((iter != results.end()) 66 94 && (iter->second != NoResult) 95 && (iter->second != NoResultQueued) 67 96 && (iter->second != ResultDelivered)); 68 97 } … … 81 110 "FragmentQueue::pushResult() - job "+toString(jobid)+" is not known to us."); 82 111 ASSERT(iter->second != NoResult, 83 "FragmentQueue::pushResult() - job "+toString(jobid)+"'s result has not arrived yet."); 112 "FragmentQueue::pushResult() - job "+toString(jobid)+" has not been request for calculation yet."); 113 ASSERT(iter->second != NoResultQueued, 114 "FragmentQueue::pushResult() - job "+toString(jobid)+"'s calculation is underway but not result has arrived yet."); 84 115 ASSERT(iter->second != ResultDelivered, 85 116 "FragmentQueue::pushResult() - job "+toString(jobid)+"'s result has already been delivered."); … … 104 135 ASSERT(iter != results.end(), 105 136 "FragmentQueue::pushResult() - job "+toString(result.getId())+" is not known to us."); 106 ASSERT(iter->second == NoResult ,137 ASSERT(iter->second == NoResultQueued, 107 138 "FragmentQueue::pushResult() - is not waiting for the result of job "+toString(result.getId())+"."); 108 139 /// and overwrite NoResult in found entry -
src/Fragmentation/Automation/FragmentQueue.hpp
r57876b r12d15a 36 36 // entering jobs into queue 37 37 void pushJob(FragmentJob &job); 38 FragmentJob popJob(); 39 bool isJobPresent() const; 38 40 39 41 // querying for results … … 42 44 void pushResult(FragmentResult &result); 43 45 44 45 46 private: 47 //!> result that takes place in ResultQueue after job has arrived before it has been popped. 48 static FragmentResult NoResult; 46 49 //!> result that takes place in ResultQueue until real result has arrived. 47 static FragmentResult NoResult ;50 static FragmentResult NoResultQueued; 48 51 //!> result that takes place in ResultQueue after real result has been delivered. 49 52 static FragmentResult ResultDelivered; -
src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.cpp
r57876b r12d15a 66 66 testJob.outputfile = std::string("do something"); 67 67 68 CPPUNIT_ASSERT_EQUAL(false, queue->isJobPresent() ); 69 68 70 #ifndef NDEBUG 69 71 CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) ); … … 73 75 74 76 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size()); 77 CPPUNIT_ASSERT_EQUAL(true, queue->isJobPresent() ); 78 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size()); 79 FragmentQueue::ResultMap::const_iterator iter = queue->results.find((JobId_t)1); 80 CPPUNIT_ASSERT( iter != queue->results.end() ); 81 CPPUNIT_ASSERT( FragmentQueue::NoResult == iter->second ); 75 82 76 83 // push same id again … … 81 88 82 89 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size()); 90 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size()); 91 92 FragmentJob poppedJob; 93 #ifndef NDEBUG 94 CPPUNIT_ASSERT_NO_THROW( poppedJob = queue->popJob() ); 95 #else 96 poppedJob = queue->popJob(); 97 #endif 98 CPPUNIT_ASSERT( poppedJob == testJob ); 99 100 CPPUNIT_ASSERT_EQUAL((size_t)0, queue->jobs.size()); 101 CPPUNIT_ASSERT_EQUAL(false, queue->isJobPresent() ); 102 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size()); 103 iter = queue->results.find((JobId_t)1); 104 CPPUNIT_ASSERT( iter != queue->results.end() ); 105 CPPUNIT_ASSERT( FragmentQueue::NoResultQueued == iter->second ); 106 107 #ifndef NDEBUG 108 std::cout << "The following assertion is intended and does not indicate a failure." << std::endl; 109 CPPUNIT_ASSERT_THROW( queue->popJob(), Assert::AssertionFailure ); 110 #endif 83 111 } 84 112 … … 91 119 testJob.setId(1); 92 120 testJob.outputfile = std::string("do something"); 121 #ifndef NDEBUG 122 CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) ); 123 #else 93 124 queue->pushJob(testJob); 125 #endif 126 #ifndef NDEBUG 127 CPPUNIT_ASSERT_NO_THROW( queue->popJob() ); 128 #else 129 queue->popJob(); 130 #endif 131 94 132 95 133 // prepare a result
Note:
See TracChangeset
for help on using the changeset viewer.