Example #1
0
void thorium_message_multiplexer_set_worker(struct thorium_message_multiplexer *self,
                struct thorium_worker *worker)
{
    struct core_memory_pool *pool;

    self->worker = worker;
    pool = thorium_worker_get_memory_pool(self->worker,
                            MEMORY_POOL_NAME_WORKER_PERSISTENT);

#ifdef THORIUM_MULTIPLEXER_USE_TREE
    core_red_black_tree_init(&self->timeline, sizeof(uint64_t), sizeof(int),
                    pool);
    core_red_black_tree_use_uint64_t_keys(&self->timeline);

#elif defined(THORIUM_MULTIPLEXER_USE_HEAP)
    core_binary_heap_init(&self->timeline, sizeof(uint64_t), sizeof(int),
                    CORE_BINARY_HEAP_MIN | CORE_BINARY_HEAP_UINT64_T_KEYS);
    core_binary_heap_set_memory_pool(&self->timeline, pool);

#elif defined(THORIUM_MULTIPLEXER_USE_QUEUE)

    core_queue_init(&self->timeline, sizeof(int));

#endif

    if (thorium_node_name(self->node) == 0 && thorium_worker_name(self->worker) == 0
                    && thorium_node_must_print_data(self->node)) {
        thorium_printf("[thorium] message_multiplexer: disabled=%d buffer_size_in_bytes=%d timeout_in_nanoseconds=%d\n",
                            CORE_BITMAP_GET_FLAG(self->flags, FLAG_DISABLED),
                        self->buffer_size_in_bytes, self->timeout_in_nanoseconds);
    }
}
Example #2
0
void thorium_cfs_scheduler_init(struct thorium_scheduler *self)
{
    struct thorium_cfs_scheduler *concrete_self;

    concrete_self = self->concrete_self;

    core_memory_pool_init(&concrete_self->pool, 131072, CORE_MEMORY_POOL_NAME_CFS_SCHEDULER);

    core_red_black_tree_init(&concrete_self->tree, sizeof(uint64_t),
                    sizeof(struct thorium_actor *), &concrete_self->pool);

#if 0
    core_red_black_tree_set_memory_pool(&concrete_self->tree, &concrete_self->pool);
#endif

    /*
     * Use uint64_t keys for comparison instead of a memory comparison.
     */
    core_red_black_tree_use_uint64_t_keys(&concrete_self->tree);
}