void ThreadGroup::executeTask(const TaskPtr& task)
{
    try {
        std::unique_lock<std::recursive_mutex> state_lock(execution_mtx_);
        ProfilerPtr profiler = getProfiler();
        Trace::Ptr interlude;
        if (profiler && profiler->isEnabled()) {
            TimerPtr timer = profiler->getTimer(getName());
            interlude.reset(new Trace(timer, task->getName()));
        }

        task->execute();

    } catch (const std::exception& e) {
        TaskGenerator* gen = task->getParent();
        if (gen) {
            gen->setError(e.what());
        }
    } catch (const std::string& s) {
        std::cerr << "Uncaught exception (string) exception: " << s << std::endl;

    } catch (const csapex::Failure& assertion) {
        handler_.handleAssertionFailure(assertion);

    } catch (...) {
        std::cerr << "Uncaught exception of unknown type and origin in execution of task " << task->getName() << "!" << std::endl;
        throw;
    }
}
Exemple #2
0
int ThreadPool::threadRun(){
	LOG_INFO("ThreadPool " << name() << " workThread start");
	
	while (_started) {
		TaskPtr t = getNextTask();
		int ret = t->execute();
		if (ret < 0) {
			LOG_ERROR("ThreadPool " << name() << "task execution error");
		}
	}

	LOG_INFO("ThreadPool stoped");
	return 0;
}