Changeset 3405


Ignore:
Timestamp:
Apr 7, 2015, 1:17:10 AM (8 years ago)
Author:
Peter
Message:

fixes #832

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r3402 r3405  
    8383  test/scheduler.test \
    8484  test/scheduler2.test \
     85  test/scheduler3.test \
    8586  test/segment.test test/smart_ptr.test \
    8687  test/smith_waterman.test \
  • trunk/yat/utility/Scheduler.cc

    r3402 r3405  
    22
    33/*
    4   Copyright (C) 2014 Peter Johansson
     4  Copyright (C) 2014, 2015 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2424#include "Scheduler.h"
    2525
     26#include <boost/exception.hpp>
     27
    2628#include <cassert>
    2729
     
    5052
    5153
     54  void Scheduler::interrupt(void)
     55  {
     56    workers_.interrupt_all();
     57  }
     58
     59
    5260  void Scheduler::post_process(JobPtr job)
    5361  {
     
    5563    assert(running_jobs_>=0);
    5664    job->status_ = Job::completed;
     65
     66    // check if an error occurred
     67    if (job->error_) {
     68      interrupt();
     69      boost::rethrow_exception(job->error_);
     70    }
     71
    5772    // for convenience
    5873    const std::vector<JobPtr>& vec = job->observers_;
     
    182197      }
    183198      // action
    184       (*job)();
     199      try {
     200        (*job)();
     201      }
     202      catch (...) {
     203        job->error_ = boost::current_exception();
     204        // return job to scheduler so it can act on the error
     205        completed_.push(job);
     206        // exit work and go home
     207        return;
     208      }
    185209      // return job to scheduler
    186210      completed_.push(job);
  • trunk/yat/utility/Scheduler.h

    r3402 r3405  
    2626#include "Queue.h"
    2727
     28#include <boost/exception_ptr.hpp>
    2829#include <boost/thread.hpp>
    2930#include <boost/shared_ptr.hpp>
     
    110111      unsigned priority_;
    111112      unsigned id_;
     113      boost::exception_ptr error_;
    112114    }; // end class Job
    113115
     
    127129    void add_dependency(boost::shared_ptr<Job> job,
    128130                        boost::shared_ptr<Job> prerequisite);
     131    /**
     132       \brief interrrupt all jobs
     133     */
     134    void interrupt(void);
    129135
    130136    /**
Note: See TracChangeset for help on using the changeset viewer.