Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
void embb_mtapi_id_pool_finalize(embb_mtapi_id_pool_t * that) {
  that->capacity = 0;
  that->ids_availabe = 0;
  that->get_id_position = 0;
  that->put_id_position = 0;
  embb_mtapi_alloc_deallocate(that->id_buffer);
  that->id_buffer = NULL;
  embb_mtapi_spinlock_finalize(&that->lock);
}