Ejemplo n.º 1
0
/*
 * Make sure we can arithmetic operations to set the initial value of a key and
 * to then later increment that value
 */
static enum test_result mt_incr_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
#define max_threads 30
    cb_thread_t tid[max_threads];
    item *test_item = NULL;
    void *key = "incr_test_key";
    uint64_t cas = 0;
    uint64_t res = 0;
    int ii;

    if (max_threads < 2) {
        return SKIPPED;
    }

    cb_assert(h1->allocate(h, NULL, &test_item, key,
                        strlen(key), 1, 0, 0,
                        PROTOCOL_BINARY_RAW_BYTES) == ENGINE_SUCCESS);
    cb_assert(h1->arithmetic(h, NULL, key, (int)strlen(key), true, true, 0, 1,
                          0, &cas, PROTOCOL_BINARY_RAW_BYTES,
                          &res, 0 ) == ENGINE_SUCCESS);
    h1->release(h, NULL, test_item);

    for (ii = 0; ii < max_threads; ++ii) {
        cb_assert(cb_create_thread(&tid[ii], incr_test_main, h, 0) == 0);
    }

    for (ii = 0; ii < max_threads; ++ii) {
        cb_assert(cb_join_thread(tid[ii]) == 0);
    }

    return SUCCESS;
}
Ejemplo n.º 2
0
void threads_shutdown(void)
{
    int ii;
    for (ii = 0; ii < nthreads; ++ii) {
        notify_thread(&threads[ii]);
        cb_join_thread(thread_ids[ii]);
    }
}
Ejemplo n.º 3
0
void stop_assoc_maintenance_thread() {
    cb_mutex_enter(&cache_lock);
    do_run_maintenance_thread = 0;
    cb_cond_signal(&maintenance_cond);
    cb_mutex_exit(&cache_lock);

    /* Wait for the maintenance thread to stop */
    cb_join_thread(maintenance_tid);
}