Пример #1
0
as_status
as_event_command_execute(as_event_command* cmd, as_error* err)
{
    ck_pr_inc_32(&cmd->cluster->async_pending);

    // Only do this after the above increment to avoid a race with as_cluster_destroy().
    if (!cmd->cluster->valid) {
        as_event_command_free(cmd);
        return as_error_set_message(err, AEROSPIKE_ERR_CLIENT, "Client shutting down");
    }

    // Use pointer comparison for performance.
    // If portability becomes an issue, use "pthread_equal(event_loop->thread, pthread_self())"
    // instead.
    if (cmd->event_loop->thread == pthread_self()) {
        // We are already in event loop thread, so start processing.
        as_event_command_begin(cmd);
    }
    else {
        if (cmd->timeout_ms) {
            // Store current time in first 8 bytes which is not used yet.
            *(uint64_t*)cmd = cf_getms();
        }

        // Send command through queue so it can be executed in event loop thread.
        if (! as_event_send(cmd)) {
            as_event_command_free(cmd);
            return as_error_set_message(err, AEROSPIKE_ERR_CLIENT, "Failed to queue command");
        }
    }
    return AEROSPIKE_OK;
}
Пример #2
0
void
as_uv_timer_closed(uv_handle_t* handle)
{
	as_event_command_free(handle->data);
}