Macro ffi_helpers::export_task
[−]
[src]
macro_rules! export_task { ($( #[$attr:meta] )* Task: $Task:ty; spawn: $spawn:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; poll: $poll:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; handle_destroy: $handle_destructor:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; result_destroy: $result_destroy:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; wait: $wait:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; cancel: $cancel:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty; cancelled: $cancelled:ident; $( $tokens:tt )*) => { ... }; ($( #[$attr:meta] )* Task: $Task:ty;) => { ... }; }
Convenience macro to define the FFI bindings for working with a Task
.
This is implemented as an incremental TT muncher which lets you define the functions you'll need. These are:
spawn
: The function for spawning a task on a background thread, returning aTaskHandle
poll
: A function for receiving the result if it's availablewait
: Block the current thread until we get either a result or an errorcancel
: Cancel the background taskcancelled
: Has the task already been cancelled?result_destroy
: A destructor for the task's resulthandle_destroy
: A destructor for theTaskHandle
, for cleaning up the task once you're done with it
You'll always need to provide the concrete Task
type in the macro's first
"argument".