void thorium_cfs_scheduler_destroy(struct thorium_scheduler *self)
{
    struct thorium_cfs_scheduler *concrete_self;

    concrete_self = self->concrete_self;

    core_red_black_tree_destroy(&concrete_self->tree);

    CORE_DEBUGGER_ASSERT(core_memory_pool_profile_balance_count(&concrete_self->pool) == 0);

    core_memory_pool_destroy(&concrete_self->pool);
}
Exemple #2
0
void thorium_message_multiplexer_destroy(struct thorium_message_multiplexer *self)
{
    int i;
    int size;
    struct thorium_multiplexed_buffer *multiplexed_buffer;
    float ratio;

    if (thorium_node_must_print_data(self->node)) {

        ratio = 0.0;

        if (self->original_message_count != 0) {
            ratio = self->real_message_count / (0.0 + self->original_message_count);

            /*
             * Jack M. Nilles
             * "Traffic reduction by telecommuting: A status review and selected bibliography"
             * Transportation Research Part A: General
             * Volume 22, Issue 4, July 1988, Pages 301–317.
             *
             * @see http://www.sciencedirect.com/science/article/pii/0191260788900088
             * @see http://ww2.cityofpasadena.net/councilagendas/2007%20agendas/feb_26_07/pasadena%20traffic%20reduction%20strategies%2011-20-06%20draft.pdf
             */
            thorium_printf("[thorium] node %d worker %d message_multiplexer:"
                            " original_message_count %d real_message_count %d (traffic reduction: %.2f%%)\n",
                            thorium_node_name(self->node), thorium_worker_name(self->worker),
                    self->original_message_count, self->real_message_count, (1.0 - ratio) * 100);

            thorium_message_multiplexer_print_traffic_reduction(self);
        }
    }

#ifdef CORE_DEBUGGER_ASSERT_ENABLED
#endif
    size = core_vector_size(&self->buffers);

#ifdef THORIUM_MULTIPLEXER_TRACK_BUFFERS_WITH_CONTENT
    /*
     * There can be no messages that are not flushed already.
     */
    CORE_DEBUGGER_ASSERT(core_set_empty(&self->buffers_with_content));

    core_set_destroy(&self->buffers_with_content);
#endif

    for (i = 0; i < size; ++i) {
        multiplexed_buffer = core_vector_at(&self->buffers, i);

        CORE_DEBUGGER_ASSERT(thorium_multiplexed_buffer_current_size(multiplexed_buffer) == 0);

        thorium_multiplexed_buffer_destroy(multiplexed_buffer);
    }

    core_vector_destroy(&self->buffers);

    self->node = NULL;

    self->buffer_size_in_bytes = -1;
    self->timeout_in_nanoseconds = -1;

    core_timer_destroy(&self->timer);

#ifdef THORIUM_MULTIPLEXER_USE_TREE
    core_red_black_tree_destroy(&self->timeline);
#elif defined(THORIUM_MULTIPLEXER_USE_HEAP)
    core_binary_heap_destroy(&self->timeline);
#elif defined(THORIUM_MULTIPLEXER_USE_QUEUE)
    core_queue_destroy(&self->timeline);

#endif

    thorium_decision_maker_destroy(&self->decision_maker);

    thorium_router_destroy(&self->router);
}