firebase::FutureBase

#include <future.h>

Type-independent return type of asynchronous calls.

Summary

See also:Future for code samples.

Inheritance

Direct Known Subclasses:firebase::Future< ResultType >

Constructors and Destructors

FutureBase()
Construct an untyped future.
FutureBase(const FutureBase & rhs)
Copy constructor and operator.
~FutureBase()

Public types

CompletionCallback)(const FutureBase &result_data, void *user_data) typedef
void(*
Function pointer for a completion callback.

Public functions

Error() const
FIREBASE_DEPRECATED int
Deprecated. Renamed to error().
When status() is kFutureStatusComplete, returns the API-defined error code.
ErrorMessage() const
FIREBASE_DEPRECATED const char *
Deprecated. Renamed to error_message().
When status() is kFutureStatusComplete, returns the API-defined error message, as human-readable text, or an empty string if the API does not provide a human readable description of the error.
OnCompletion(CompletionCallback callback, void *user_data) const
void
Register a callback that will be called at most once, when the future is completed.
Release()
void
Explicitly release the internal resources for a future.
ResultVoid() const
FIREBASE_DEPRECATED const void *
Deprecated. Renamed to result_void().
Result of the asynchronous call, or nullptr if the result is still pending.
Status() const
FIREBASE_DEPRECATED FutureStatus
Deprecated. Renamed to status().
Completion status of the asynchronous call.
error() const
int
When status() is kFutureStatusComplete, returns the API-defined error code.
error_message() const
const char *
When status() is kFutureStatusComplete, returns the API-defined error message, as human-readable text, or an empty string if the API does not provide a human readable description of the error.
operator=(const FutureBase & rhs)
Copy an untyped future.
result_void() const
const void *
Result of the asynchronous call, or nullptr if the result is still pending.
status() const
Completion status of the asynchronous call.

Public types

CompletionCallback

void(* CompletionCallback)(const FutureBase &result_data, void *user_data)

Function pointer for a completion callback.

When we call this, we will send the completed future, along with the user data that you specified when you set up the callback.

Public functions

Error

FIREBASE_DEPRECATED int Error() const 

When status() is kFutureStatusComplete, returns the API-defined error code.

Otherwise, return value is undefined.

Deprecated. Renamed to error().

ErrorMessage

FIREBASE_DEPRECATED const char * ErrorMessage() const 

When status() is kFutureStatusComplete, returns the API-defined error message, as human-readable text, or an empty string if the API does not provide a human readable description of the error.

Note:The returned pointer is only valid for the lifetime of the Future or its copies. Deprecated. Renamed to error_message().

FutureBase

 FutureBase()

Construct an untyped future.

FutureBase

 FutureBase(
  const FutureBase & rhs
)

Copy constructor and operator.

Increment the reference count when creating a copy of the future.

OnCompletion

void OnCompletion(
  CompletionCallback callback,
  void *user_data
) const 

Register a callback that will be called at most once, when the future is completed.

If you call OnCompletion() itself more than once, only the most recent callback you registered be called.

When your callback is called, the user_data that you supplied here will be passed back as the second parameter.

Details
Parameters
callback
Function pointer to your callback.
user_data
Optional user data. We will pass this back to your callback.

Release

void Release()

Explicitly release the internal resources for a future.

Future will become invalid.

ResultVoid

FIREBASE_DEPRECATED const void * ResultVoid() const 

Result of the asynchronous call, or nullptr if the result is still pending.

Cast is required since GetFutureResult() returns void*.

Deprecated. Renamed to result_void().

Status

FIREBASE_DEPRECATED FutureStatus Status() const 

Completion status of the asynchronous call.

Deprecated. Renamed to status().

error

int error() const 

When status() is kFutureStatusComplete, returns the API-defined error code.

Otherwise, return value is undefined.

error_message

const char * error_message() const 

When status() is kFutureStatusComplete, returns the API-defined error message, as human-readable text, or an empty string if the API does not provide a human readable description of the error.

Note:The returned pointer is only valid for the lifetime of the Future or its copies.

operator=

FutureBase & operator=(
  const FutureBase & rhs
)

Copy an untyped future.

result_void

const void * result_void() const 

Result of the asynchronous call, or nullptr if the result is still pending.

Cast is required since GetFutureResult() returns void*.

status

FutureStatus status() const 

Completion status of the asynchronous call.

~FutureBase

 ~FutureBase()

Send feedback about...

Need help? Visit our support page.