Menu

CassFuture

struct CassFuture

The future result of an operation.

It can represent a result if the operation completed successfully or an error if the operation failed. It can be waited on, polled or a callback can be attached.

Public Functions

void cass_future_free(CassFuture *future)

Frees a future instance. A future can be freed anytime.

CassError cass_future_set_callback(CassFuture *future, CassFutureCallback callback, void *data)

Sets a callback that is called when a future is set

Return

CASS_OK if successful, otherwise an error occurred

Parameters
  • future:

  • callback:

  • data:

cass_bool_t cass_future_ready(CassFuture *future)

Gets the set status of the future.

Return

true if set

Parameters
  • future:

void cass_future_wait(CassFuture *future)

Wait for the future to be set with either a result or error.

Important: Do not wait in a future callback. Waiting in a future callback will cause a deadlock.

Parameters
  • future:

cass_bool_t cass_future_wait_timed(CassFuture *future, cass_duration_t timeout_us)

Wait for the future to be set or timeout.

Return

false if returned due to timeout

Parameters
  • future:

  • timeout_us: wait time in microseconds

const CassResult *cass_future_get_result(CassFuture *future)

Gets the result of a successful future. If the future is not ready this method will wait for the future to be set.

Return

CassResult instance if successful, otherwise NULL for error. The return instance must be freed using cass_result_free().

See

cass_session_execute() and cass_session_execute_batch()

Parameters
  • future:

const CassErrorResult *cass_future_get_error_result(CassFuture *future)

Gets the error result from a future that failed as a result of a server error. If the future is not ready this method will wait for the future to be set.

Return

CassErrorResult instance if the request failed with a server error, otherwise NULL if the request was successful or the failure was not caused by a server error. The return instance must be freed using cass_error_result_free().

See

cass_session_execute() and cass_session_execute_batch()

Parameters
  • future:

const CassPrepared *cass_future_get_prepared(CassFuture *future)

Gets the result of a successful future. If the future is not ready this method will wait for the future to be set. The first successful call consumes the future, all subsequent calls will return NULL.

Return

CassPrepared instance if successful, otherwise NULL for error. The return instance must be freed using cass_prepared_free().

See

cass_session_prepare()

Parameters
  • future:

CassError cass_future_error_code(CassFuture *future)

Gets the error code from future. If the future is not ready this method will wait for the future to be set.

Return

CASS_OK if successful, otherwise an error occurred.

See

cass_error_desc()

Parameters
  • future:

void cass_future_error_message(CassFuture *future, const char **message, size_t *message_length)

Gets the error message from future. If the future is not ready this method will wait for the future to be set.

Parameters
  • future:

  • message: Empty string returned if successful, otherwise a message describing the error is returned.

  • message_length:

CassError cass_future_tracing_id(CassFuture *future, CassUuid *tracing_id)

Gets the tracing ID associated with the request.

Return

CASS_OK if successful, otherwise an error occurred.

Parameters
  • future:

  • tracing_id:

size_t cass_future_custom_payload_item_count(CassFuture *future)

Gets a the number of custom payload items from a response future. If the future is not ready this method will wait for the future to be set.

Requires Apache Cassandra: 2.2+

Return

the number of custom payload items.

Parameters
  • future:

CassError cass_future_custom_payload_item(CassFuture *future, size_t index, const char **name, size_t *name_length, const cass_byte_t **value, size_t *value_size)

Gets a custom payload item from a response future at the specified index. If the future is not ready this method will wait for the future to be set.

Requires Apache Cassandra: 2.2+

Return

CASS_OK if successful, otherwise an error occurred.

Parameters
  • future:

  • index:

  • name:

  • name_length:

  • value:

  • value_size:

const CassNode *cass_future_coordinator(CassFuture *future)

Gets the node that acted as coordinator for this query. If the future is not ready this method will wait for the future to be set.

Return

The coordinator node that handled the query. The lifetime of this object is the same as the result object it came from. NULL can be returned if the future is not a response future or if an error occurs before a coordinator responds.

See

cass_statement_set_node()

Parameters
  • future: