Operation API#
- <amongoc/operation.h> (header file)#
- <amongoc/operation.hpp> (header file)#
Operation state utilities.
Types#
C Types#
-
struct amongoc_operation#
Represents a composed operation ready to be launched. This is created by connecting an
amongoc_emitter
to anamongoc_handler
.- Header:
-
amongoc_box userdata#
Arbitrary data associated with the operation.
-
amongoc_handler handler#
Storage for the handler associated with the operation.
-
amongoc_start_callback start_callback#
The start callback for the operation. Do not call this directly. Prefer to use
amongoc_start()
when launching an operation.
-
as_unique() &&#
Move the operation into a new
amongoc::unique_operation
object.
-
using amongoc_start_callback = void (*)(amongoc_operation *self)#
The operation-launching callback for the operation.
C++ Types#
-
class amongoc::unique_operation#
Provides move-only ownership semantics around an
amongoc_operation
, preventing programmer error and ensuring destruction when the operation leaves scope.- Header:
-
unique_operation(amongoc_operation&&)#
Take ownership of the given
amongoc_operation
object.
-
~unique_operation()#
Calls
amongoc_operation_delete()
on the operation.
-
template<typename F>
unique_operation from_starter(unique_handler &&h, F &&fn)# Create an operation object based on a starter function
fn
with an associated handlerh
.- Parameters:
h – The handler object to be attached to the operation.
fn – The starter invocable that will be invoked whent he operation is is started. An lvalue reference to the stored handler will be passed as the sole argument to the starter function.
- Allocation:
The operation state will be allocated using the allocator associated with the handler
h
.
-
void start()#
- C API:
-
amongoc_operation release() &&#
Relinquish ownership of the wrapped operation and return it to the caller. This function is used to interface with C APIs that want to
[[transfer]]
anamongoc_operation
.
Functions & Macros#
-
void amongoc_start(amongoc_operation *op)#
Launch the operation defined by the given operation object.
- Header:
-
void amongoc_operation_delete(amongoc_operation [[transfer]] op)#
Destroy an operation object.
- Header:
Note
It is very important that the associated operation is NOT in-progress!