Pepper_31_C++_interfaces
|
#include <completion_callback.h>
Public Member Functions | |
CompletionCallback () | |
CompletionCallback (PP_CompletionCallback_Func func, void *user_data) | |
CompletionCallback (PP_CompletionCallback_Func func, void *user_data, int32_t flags) | |
void | set_flags (int32_t flags) |
void | Run (int32_t result) |
void | RunAndClear (int32_t result) |
bool | IsOptional () const |
const PP_CompletionCallback & | pp_completion_callback () const |
int32_t | flags () const |
int32_t | MayForce (int32_t result) const |
Protected Attributes | |
PP_CompletionCallback | cc_ |
This API enables you to implement and receive callbacks when Pepper operations complete asynchronously.
You can create these objects yourself, but it is most common to use the CompletionCallbackFactory to allow the callbacks to call class member functions.
Definition at line 25 of file completion_callback.h.
|
inline |
The default constructor will create a blocking CompletionCallback
that can be passed to a method to indicate that the calling thread should be blocked until the asynchronous operation corresponding to the method completes.
Note: Blocking completion callbacks are only allowed from from background threads.
Definition at line 34 of file completion_callback.h.
References cc_.
|
inline |
A constructor for creating a CompletionCallback
.
[in] | func | The function to be called on completion. |
[in] | user_data | The user data to be passed to the callback function. This is optional and is typically used to help track state in case of multiple pending callbacks. |
Definition at line 44 of file completion_callback.h.
References cc_.
|
inline |
A constructor for creating a CompletionCallback
with specified flags.
[in] | func | The function to be called on completion. |
[in] | user_data | The user data to be passed to the callback function. This is optional and is typically used to help track state in case of multiple pending callbacks. |
[in] | flags | Bit field combination of PP_CompletionCallback_Flag flags used to control how non-NULL callbacks are scheduled by asynchronous methods. |
Definition at line 58 of file completion_callback.h.
|
inline |
The flags() function returns flags used to control how non-NULL callbacks are scheduled by asynchronous methods.
PP_CompletionCallback_Flag
flags. Definition at line 130 of file completion_callback.h.
References cc_.
Referenced by CompletionCallback(), and set_flags().
|
inline |
IsOptional() is used to determine the setting of the PP_COMPLETIONCALLBACK_FLAG_OPTIONAL
flag. This flag allows any method taking such callback to complete synchronously and not call the callback if the operation would not block. This is useful when performance is an issue, and the operation bandwidth should not be limited to the processing speed of the message loop.
On synchronous method completion, the completion result will be returned by the method itself. Otherwise, the method will return PP_OK_COMPLETIONPENDING, and the callback will be invoked asynchronously on the same thread where the PPB method was invoked.
Definition at line 114 of file completion_callback.h.
References cc_.
Referenced by MayForce().
MayForce() is used when implementing functions taking callbacks. If the callback is required and result
indicates that it has not been scheduled, it will be forced on the main thread.
Example:
[in] | result | PP_OK_COMPLETIONPENDING or the result of the completed operation to be passed to the callback function. PP_OK_COMPLETIONPENDING indicates that the callback has already been scheduled. Other non-positive values correspond to error codes from pp_errors.h . Positive values indicate additional information such as bytes read. |
PP_OK_COMPLETIONPENDING
if the callback has been forced, result parameter otherwise. Definition at line 159 of file completion_callback.h.
References pp::Core::CallOnMainThread(), pp::Module::core(), pp::Module::Get(), and IsOptional().
|
inline |
The pp_completion_callback() function returns the underlying PP_CompletionCallback
PP_CompletionCallback
. Definition at line 123 of file completion_callback.h.
References cc_.
|
inline |
Run() is used to run the CompletionCallback
. Normally, the system runs a CompletionCallback
after an asynchronous operation completes, but programs may wish to run the CompletionCallback
manually in order to reuse the same code paths.
[in] | result | The result of the operation to be passed to the callback function. Non-positive values correspond to the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING ). Positive values indicate additional information such as bytes read. |
Definition at line 83 of file completion_callback.h.
|
inline |
RunAndClear() is used to run the CompletionCallback
and clear out the callback so that it cannot be run a second time.
[in] | result | The result of the operation to be passed to the callback function. Non-positive values correspond to the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING ). Positive values indicate additional information such as bytes read. |
Definition at line 96 of file completion_callback.h.
|
inline |
The set_flags() function is used to set the flags used to control how non-NULL callbacks are scheduled by asynchronous methods.
[in] | flags | Bit field combination of PP_CompletionCallback_Flag flags used to control how non-NULL callbacks are scheduled by asynchronous methods. |
Definition at line 70 of file completion_callback.h.
|
protected |
Definition at line 168 of file completion_callback.h.
Referenced by CompletionCallback(), flags(), IsOptional(), pp_completion_callback(), Run(), RunAndClear(), and set_flags().