<commit_before>#include <iostream>

#include <libport/compiler.hh>     // For ECHO
#include <libport/foreach.hh>

#include "job.hh"

namespace scheduler
{
  void
  Job::run ()
  {
    ECHO ("In Job::run for " << this);
    yield_front ();
    try {
      work ();
      terminate ();
    }
    catch (boost::exception &e)
    {
      // Signal the exception to each linked job in turn.
      boost::exception_ptr ep = boost::clone_exception (e);
      jobs to_signal = links_;
      foreach (Job* job, to_signal)
      {
	  job->async_throw (ep);
	  unlink (job);
      }
    }
    catch (...)
    {
      // Exception is lost and cannot be propagated properly
      std::cerr << "Exception caught in job " << this << ", loosing it\n";
    }

    terminate_cleanup ();
    yield ();

    // We should never go there as the scheduler will have terminated us.
    assert (false);
  }

  void
  Job::terminate_now ()
  {
    terminate ();
    terminate_cleanup ();
  }
<commit_msg>Do not doubly terminate a task<commit_after>#include <iostream>

#include <libport/compiler.hh>     // For ECHO
#include <libport/foreach.hh>

#include "job.hh"

namespace scheduler
{
  void
  Job::run ()
  {
    ECHO ("In Job::run for " << this);
    yield_front ();
    try {
      work ();
      terminate ();
    }
    catch (boost::exception &e)
    {
      // Signal the exception to each linked job in turn.
      boost::exception_ptr ep = boost::clone_exception (e);
      jobs to_signal = links_;
      foreach (Job* job, to_signal)
      {
	  job->async_throw (ep);
	  unlink (job);
      }
    }
    catch (...)
    {
      // Exception is lost and cannot be propagated properly
      std::cerr << "Exception caught in job " << this << ", loosing it\n";
    }

    terminate_cleanup ();
    yield ();

    // We should never go there as the scheduler will have terminated us.
    assert (false);
  }

  void
  Job::terminate_now ()
  {
    if (!terminated_)
    {
      terminate ();
      terminate_cleanup ();
    }
  }

{'fraction_non_alphanumeric': 0.13276976628543014, 'fraction_numerical': 0.0, 'mean_word_length': 2.2243589743589745, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4585667', 'n_tokens_mistral': 659, 'n_tokens_neox': 636, 'n_words': 183}