BpAtom Class Reference

#include <support/Binder.h>

Inheritance diagram for BpAtom:

SAtom BpInterface BpInterface< IByteInput > BpInterface< IByteOutput > BpInterface< IByteSeekable > BpInterface< IMemory > BpInterface< IMemoryDealer > BpInterface< IMemoryHeap > BpInterface< IStorage > BpInterface< IXMLOStr > List of all members.

Detailed Description

This is the SAtom protocol implementation for a proxy interface.

You don't normally use this directly -- it is included as part of the BpInterface<> implementation below.


Protected Member Functions

 BpAtom (const sptr< IBinder > &o)
virtual status_t DeleteAtom (const void *id)
 Called after last DecRefs() when the life of an atom is extended.
virtual status_t FinishAtom (const void *id)
 Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).
virtual status_t IncStrongAttempted (uint32_t flags, const void *id)
 Called during IncStrong() after an atom has been released.
virtual void InitAtom ()
 Called the first time a strong reference is acquired. All significant object initialization should go here.
IBinderRemote () const
IBinderRemote ()
virtual ~BpAtom ()


Constructor & Destructor Documentation

BpAtom const sptr< IBinder > &  o  )  [protected]
 

~BpAtom  )  [protected, virtual]
 


Member Function Documentation

status_t DeleteAtom const void *  id  )  [protected, virtual]
 

Called after last DecRefs() when the life of an atom is extended.

If you override FinishAtom() to not call into SAtom (and thus extend the life of your object), then this method will be called when its last reference goes away. The default implementation returns B_OK to have the object deleted. You can override this to return an error code so that the object is not destroyed.

This is a very, very unusual feature and requires a lot of careful and specific management of objects and reference counts to make work. You probably want to leave it as-is.

See also:
DecWeak(), FinishAtom()

Reimplemented from SAtom.

Reimplemented in BpInterface, BpInterface< IStorage >, BpInterface< IMemoryDealer >, BpInterface< IXMLOStr >, BpInterface< IMemory >, BpInterface< IByteOutput >, BpInterface< IByteInput >, BpInterface< IMemoryHeap >, and BpInterface< IByteSeekable >.

status_t FinishAtom const void *  id  )  [protected, virtual]
 

Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).

If you return FINISH_ATOM_ASYNC here, your object's destructor will be called asynchronously from the current thread. This is highly recommend if you must acquire a lock in the destructor, to avoid unexpected deadlocks due to things like sptr<> going out of scope while a lock is held.

If you return an error code here, the object's destructor will not be called at this point.

The default implementation will return B_OK, allowing the SAtom destruction to proceed as normal. Don't override this method unless you want some other behavior. Like InitAtom(), you do not need to call the SAtom implementation.

See also:
DecStrong()

Reimplemented from SAtom.

Reimplemented in BpInterface, BpInterface< IStorage >, BpInterface< IMemoryDealer >, BpInterface< IXMLOStr >, BpInterface< IMemory >, BpInterface< IByteOutput >, BpInterface< IByteInput >, BpInterface< IMemoryHeap >, and BpInterface< IByteSeekable >.

status_t IncStrongAttempted uint32_t  flags,
const void *  id
[protected, virtual]
 

Called during IncStrong() after an atom has been released.

The flags will be B_ATOM_FIRST_STRONG if this is the first strong reference ever acquired on the atom. The default implementation returns B_OK if B_ATOM_FIRST_STRONG is set, otherwise it returns B_NOT_ALLOWED to make the attempted IncStrong() fail.

You can override this to return B_OK when you would like an atom to continue allowing primary references. Note that this also requires overriding FinishAtom() to return an error code, extending the lifetime of the object. Like FinishAtom(), you do not need to call the SAtom implementation.

See also:
AttemptIncStrong(), FinishAtom()

Reimplemented from SAtom.

Reimplemented in BpInterface, BpInterface< IStorage >, BpInterface< IMemoryDealer >, BpInterface< IXMLOStr >, BpInterface< IMemory >, BpInterface< IByteOutput >, BpInterface< IByteInput >, BpInterface< IMemoryHeap >, and BpInterface< IByteSeekable >.

void InitAtom  )  [protected, virtual]
 

Called the first time a strong reference is acquired. All significant object initialization should go here.

You can override it and do any setup you need. Note that you do not need to call the SAtom implementation. (So you can derive from two different SAtom implementations and safely call down to both of their IncStrong() methods.)

See also:
IncStrong()

Reimplemented from SAtom.

Reimplemented in BpInterface, BpInterface< IStorage >, BpInterface< IMemoryDealer >, BpInterface< IXMLOStr >, BpInterface< IMemory >, BpInterface< IByteOutput >, BpInterface< IByteInput >, BpInterface< IMemoryHeap >, and BpInterface< IByteSeekable >.

IBinder* Remote  )  const [inline, protected]
 

IBinder* Remote  )  [inline, protected]
 


The documentation for this class was generated from the following files: