Esempio n. 1
0
void insert_task_thread_pool(struct thread_pool_t *thread_pool, struct thread_pool_task_t *thread_pool_task) {
    /* locks the task condition lock */
    CONDITION_LOCK(thread_pool->task_condition, thread_pool->task_condition_lock);

    /* adds the the thread pool task to the task queue */
    append_value_linked_list(thread_pool->task_queue, thread_pool_task);

    /* signals the task condition */
    CONDITION_SIGNAL(thread_pool->task_condition);

    /* unlock the task condition lock */
    CONDITION_UNLOCK(thread_pool->task_condition, thread_pool->task_condition_lock);
}
Esempio n. 2
0
void
shardcache_client_destroy(shardcache_client_t *c)
{
    if (c->thread) {
        __sync_fetch_and_add(&c->quit, 1);
        pthread_join(c->thread, NULL);
        CONDITION_SIGNAL(c->wakeup_cond, c->wakeup_lock);
        CONDITION_DESTROY(c->wakeup_cond);
        MUTEX_DESTROY(c->wakeup_lock);
    }
    queue_destroy(c->async_jobs);
    chash_free(c->chash);
    shardcache_free_nodes(c->shards, c->num_shards);
    free((void *)c->auth);
    connections_pool_destroy(c->connections);
    free(c);
}