bare::ffi::objc::block
On this page
- Structs
- Implementations
impl Descriptor1
Nabi closures as Objective-C blocks, laid out as the Apple block ABI says.
A block holds one word: the address of a pinned GC cell holding the
closure. Pinned objects stay where they are and are roots, and the
pin count is the number of blocks that hold the cell, so the closure
lives as long as any copy Objective-C keeps. extern "objc" methods
with a closure parameter make the block, and the trampoline its
invoke calls, themselves.
Block<F> is a block Nabi owns, for C functions that take one
(dispatch_async); the collector releases it. BlockRef<F> is a
block Objective-C passed in, which copy() keeps.
Structs
BlockSource
pub struct Block<F>A block Nabi owns (one _Block_copy retain, which the collector
gives back), calling a closure of type F. Pass it to a C function
with as_raw().
Own heap block
b(a+1one, from_Block_copyornew).Safety:
bis a heap block calling anF, owned once.The block, for a C parameter of block type (
dispatch_block_t). A callee that keeps it copies it.A block calling
f, on any thread or queue.A block calling
f, which need not beSend: it may run only on the main thread (main-queue APIs), and panics anywhere else.Call the closure, as Objective-C would.
BlockRefSource
pub struct BlockRef<F>A block Objective-C passed in (a completion handler): valid while the
call that passed it runs; copy() keeps it longer.
The block at
p.Safety:
pis a block calling anF, alive while this is used.The block, kept:
_Block_copy, released by the collector.The block, to pass on to a C parameter during the call.
Call the block.
Implementations
impl Descriptor
The descriptor of blocks with type encoding
signature("v@?@"), a string literal.