Function binder_ndk_sys::AIBinder_Weak_lt

source ·
pub unsafe extern "C" fn AIBinder_Weak_lt(
    lhs: *const AIBinder_Weak,
    rhs: *const AIBinder_Weak,
) -> bool
Expand description

Whether AIBinder_Weak is less than another.

This provides a per-process-unique total ordering of binders which is exactly the same as AIBinder_lt. Similarly, a null AIBinder_Weak* is considered to be ordered before all other weak references.

This function correctly distinguishes binders even if one is deallocated. So, for instance, an AIBinder_Weak* entry representing a deleted binder will never compare as equal to an AIBinder_Weak* entry which represents a different allocation of a binder, even if the two binders were originally allocated at the same address. That is:

AIBinder* a = ...; // imagine this has address 0x8
AIBinder_Weak* bWeak = AIBinder_Weak_new(a);
AIBinder_decStrong(a); // a may be deleted, if this is the last reference
AIBinder* b = ...; // imagine this has address 0x8 (same address as b)
AIBinder_Weak* bWeak = AIBinder_Weak_new(b);

Then when a/b are compared with other binders, their order will be preserved, and it will either be the case that AIBinder_Weak_lt(aWeak, bWeak) OR AIBinder_Weak_lt(bWeak, aWeak), but not both.

Unlike AIBinder*, the AIBinder_Weak* addresses themselves have nothing to do with the underlying binder.

Available since API level 31.

\param lhs comparison object \param rhs comparison object

\return whether “lhs < rhs” is true