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(constFutureBase & rhs)Copy constructor and operator. | |
~FutureBase() |
Public types | |
|---|---|
CompletionCallback)(const FutureBase &result_data, void *user_data) | typedefvoid(*Function pointer for a completion callback. |
Public functions | |
|---|---|
OnCompletion(CompletionCallback callback, void *user_data) const | voidRegister a single callback that will be called at most once, when the future is completed. |
OnCompletion(std::function< void(constFutureBase &)> callback) const | voidRegister a single callback that will be called at most once, when the future is completed. |
Release() | voidExplicitly release the internal resources for a future. |
error() const | intWhenstatus() isfirebase::kFutureStatusComplete, returns the API-defined error code. |
error_message() const | const char *Whenstatus() isfirebase::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!=(constFutureBase & rhs) const | boolReturns true if the two Futures reference different results. |
operator=(constFutureBase & rhs) | Copy an untyped future. |
operator==(constFutureBase & rhs) const | boolReturns true if the two Futures reference the same result. |
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)(constFutureBase&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
FutureBase
FutureBase()
Construct an untyped future.
FutureBase
FutureBase(constFutureBase&rhs)
Copy constructor and operator.
Increment the reference count when creating a copy of the future.
OnCompletion
voidOnCompletion(CompletionCallbackcallback,void*user_data)const
Register a single callback that will be called at most once, when the future is completed.
If you call anyOnCompletion() method more than once on the same future, only the most recent callback you registered withOnCompletion() will be called. When your callback is called, the user_data that you supplied here will be passed back as the second parameter.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
OnCompletion
voidOnCompletion(std::function<void(constFutureBase&)>callback)const
Register a single callback that will be called at most once, when the future is completed.
If you call anyOnCompletion() method more than once on the same future, only the most recent callback you registered withOnCompletion() will be called.Note: This method is not available when using STLPort on Android, asstd::function is not supported on STLPort.
| Details | |||
|---|---|---|---|
| Parameters |
|
Release
voidRelease()
Explicitly release the internal resources for a future.
Future will become invalid.
error
interror()const
Whenstatus() isfirebase::kFutureStatusComplete, returns the API-defined error code.
Otherwise, return value is undefined.
error_message
constchar*error_message()const
Whenstatus() isfirebase::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 theFuture or its copies.
operator!=
booloperator!=(constFutureBase&rhs)const
Returns true if the two Futures reference different results.
operator==
booloperator==(constFutureBase&rhs)const
Returns true if the two Futures reference the same result.
result_void
constvoid*result_void()const
Result of the asynchronous call, or nullptr if the result is still pending.
Cast is required since GetFutureResult() returns void*.
~FutureBase
~FutureBase()
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-23 UTC.