コード例 #1
0
ファイル: job_node.c プロジェクト: atgeirr/ResInsight
bool job_queue_node_kill( job_queue_node_type * node , job_queue_status_type * status , queue_driver_type * driver) {
  bool result = false;
  pthread_mutex_lock( &node->data_mutex );
  {
    job_status_type current_status = job_queue_node_get_status( node );
    if (current_status & JOB_QUEUE_CAN_KILL) {
      /*
         Jobs with status JOB_QUEUE_WAITING are killable - in the
         sense that status should be set to JOB_QUEUE_USER_KILLED; but
         they do not have any driver specific job_data, and the
         driver->kill_job() function can NOT be called.
      */
      if (current_status != JOB_QUEUE_WAITING) {
        queue_driver_kill_job( driver , node->job_data );
        if (node->job_data) {
          queue_driver_free_job( driver , node->job_data );
          node->job_data = NULL;
        }
      }
      job_queue_status_transition(status, current_status, JOB_QUEUE_USER_KILLED);
      job_queue_node_set_status( node , JOB_QUEUE_USER_KILLED);
      result = true;
    }
  }
  pthread_mutex_unlock( &node->data_mutex );
  return result;
}
コード例 #2
0
ファイル: job_node.c プロジェクト: flikka/ert
bool job_queue_node_kill( job_queue_node_type * node , job_queue_status_type * status , queue_driver_type * driver) {
  bool result = false;
  pthread_mutex_lock( &node->data_mutex );
  {
    job_status_type current_status = job_queue_node_get_status( node );
    if (current_status & JOB_QUEUE_CAN_KILL) {
      /*
        If the job is killed before it is even started no driver
        specific job data has been assigned; we therefor must check
        the node->job_data pointer before entering.
      */
      if (node->job_data) {
        queue_driver_kill_job( driver , node->job_data );
        queue_driver_free_job( driver , node->job_data );
        node->job_data = NULL;
      }
      job_queue_status_transition(status, current_status, JOB_QUEUE_USER_KILLED);
      job_queue_node_set_status( node , JOB_QUEUE_USER_KILLED);
      result = true;
    }
  }
  pthread_mutex_unlock( &node->data_mutex );
  return result;
}