/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * SpecificFragmentController.cpp * * Created on: Aug 27, 2012 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif // boost asio needs specific operator new #include #include "CodePatterns/MemDebug.hpp" #include "SpecificFragmentController.hpp" #include "CodePatterns/Info.hpp" void SpecificFragmentController::RunService(std::string message) { message = std::string("io_service: ") + message; io_service.reset(); Info info(message.c_str()); io_service.run(); } void SpecificFragmentController::requestIds(const size_t numberjobs) { FragmentController::requestIds(host, port, numberjobs); RunService("Requesting ids"); } void SpecificFragmentController::waitforResults(const size_t NoExpectedResults) { size_t NoCalculatedResults = 0; while (NoCalculatedResults != NoExpectedResults) { // wait a bit boost::asio::deadline_timer timer(io_service); timer.expires_from_now(boost::posix_time::milliseconds(500)); timer.wait(); // then request status FragmentController::checkResults(host, port); RunService("Checking on results"); const std::pair JobStatus = FragmentController::getJobStatus(); LOG(1, "INFO: #" << JobStatus.first << " are waiting in the queue and #" << JobStatus.second << " jobs are calculated so far."); NoCalculatedResults = JobStatus.second; } }