Crate android_looper [] [src]

Fork me on GitHub

From android docs:

Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.

Library design conventions

This library is a minimal safe wrapper for what otherwise be unsafe ffi bindings. There are few conventions used here that are good to know to make the best use of it.

Safety does not include the correct destruction order

While this library may provide the RAII wrappers (see bellow), it will not keep track of wrapper dependencies. Doing it at this level would require Rc machinery that may cause several problems: force users to use Rc or Arc, complicate implementation, no longer be zero-cost.

Instead, the users are encouraged to build wrappers around these different type kinds (listed bellow) that manage resources as needed for each use case.

Not-copyable struct Object kind

This is RAII type that wraps a low-level resource, provides methods to manipulate it and also destroys it when it goes out of scope. It may also have convenience methods from_handle as constructor and method forget to get back the handle and disable the RAII.

Copyable struct/enum Object kind

Used for tracking intermediate glue information, usually replaces or wraps cumbersome C unions, types or enums.

Copyable struct ObjectRef kind

Wraps a low level handle(s) and provides methods to manipulate it/them. Used in situations where the handle lifetime is controlled by another object or it is some kind of global singleton. In such cases the method calls themselves may return errors when called on expired or invalid handle.

Modules

error

Looper Error and Result.

Structs

AcquiredLooper

RAII acquired looper wrapper.

LooperRef

Reference to a looper.

Enums

LooperPrepareOpts

Option for for ALooper_prepare().

Type Definitions

LooperHandle