Beispiel #1
0
void embb_mtapi_group_finalize(embb_mtapi_group_t * that) {
  assert(MTAPI_NULL != that);

  that->deleted = MTAPI_TRUE;
  that->num_tasks.internal_variable = 0;
  embb_mtapi_task_queue_finalize(&that->queue);
}
void embb_mtapi_thread_context_finalize(embb_mtapi_thread_context_t* that) {
  mtapi_uint_t ii;

  assert(MTAPI_NULL != that);

  embb_mtapi_log_trace("embb_mtapi_thread_context_finalize() called\n");

  if (that->is_initialized) {
    if (that->is_main_thread) {
      embb_tss_delete(&that->tss_id);
    }
    embb_condition_destroy(&that->work_available);
    embb_mutex_destroy(&that->work_available_mutex);
  }

  if (that->queue != NULL) {
    for (ii = 0; ii < that->priorities; ii++) {
      if (that->queue[ii] != NULL) {
        embb_mtapi_task_queue_finalize(that->queue[ii]);
        embb_mtapi_alloc_deallocate(that->queue[ii]);
        that->queue[ii] = MTAPI_NULL;
      }
    }
    embb_mtapi_alloc_deallocate(that->queue);
    that->queue = MTAPI_NULL;
  }

  if (that->private_queue != NULL) {
    for (ii = 0; ii < that->priorities; ii++) {
      if (that->private_queue[ii] != NULL) {
        embb_mtapi_task_queue_finalize(that->private_queue[ii]);
        embb_mtapi_alloc_deallocate(that->private_queue[ii]);
        that->private_queue[ii] = MTAPI_NULL;
      }
    }
    embb_mtapi_alloc_deallocate(that->private_queue);
    that->private_queue = MTAPI_NULL;
  }

  embb_atomic_destroy_int(&that->is_sleeping);
  embb_atomic_destroy_int(&that->run);

  that->priorities = 0;
  that->is_initialized = MTAPI_FALSE;

  that->node = MTAPI_NULL;
}