template <typename Export, typename Import>

class ObjectLinker

Defined at line 218 of file ../../src/ui/scenic/lib/utils/object_linker.h

Allows direct linking of peer objects, regardless of which session(s) they

exist in. Once the objects are linked, they have direct references to each

other.

This linking is accomplished via lookup between pairable kernel objects.

zx::eventpair objects are a natural fit for this purpose and are commonly

used.

To create a Link, provide a handle to one half of a pairable kernel object

(zx::object_traits:supports_duplication is true) to the |CreateExport| or

|CreateImport| methods. It can be connected with its peer by providing a

concrete object to link along with callbacks for both successful and

unsuccessful resolution. Import and Export should be copy constructable as

they might be relinked.

When the other half of the kernel object is registered with the

ObjectLinker, and Initialize() is called on the corresponding Link, the

provided resolution callbacks in both Links will be fired. The callback

associated with the Export will always fire first.

If either Link endpoint is destroyed, this will cause the provided

disconnection callback on its peer endpoint to be fired. If the peer

endpoint has not been provided any callbacks yet via Initialize(), the

disconnection callback will be fired later when Initialize() is first called

on it.

Attempts to register either half of the kernel object multiple times, even

through cloned handles, will result in an error.

TODO(https://fxbug.dev/42098134): Allow multiple Imports.

Thread-safety: this class is thread-safe. Links may be created and used on multiple threads.

Links must be destroyed before their dispatcher is destroyed (i.e. the default dispatcher when

the Link is created).

Public Methods

std::shared_ptr<ObjectLinker<Export, Import>> New ()

Defined at line 304 of file ../../src/ui/scenic/lib/utils/object_linker.h

void ~ObjectLinker<Export, Import> ()

Defined at line 307 of file ../../src/ui/scenic/lib/utils/object_linker.h

template <typename T, typename = std::enable_if_t<zx::object_traits<T>::has_peer_handle>>
ExportLink CreateExport (Export export_obj, T token, ErrorReporter * error_reporter)

Creates an outgoing cross-session ExportLink between two objects,

which can be used to initiate and close the connection between them.

The ObjectLinker uses the provided |token| to locate the paired ImportLink.

|token| must reference a pairable kernel object type such as |zx::channel| or |zx::eventpair|.

|token| may not reference a kernel object that is in use by this ObjectLinker.

If a link cannot be created, |error_reporter| will be used to flag an error.

The objects are linked as soon as the |Initialize()| method is called on

the links for both objects.

Defined at line 321 of file ../../src/ui/scenic/lib/utils/object_linker.h

template <typename T, typename = std::enable_if_t<zx::object_traits<T>::has_peer_handle>>
ImportLink CreateImport (Import import_obj, T token, ErrorReporter * error_reporter)

Creates an incoming cross-session ImportLink between two objects,

which can be used to initiate and close the connection between them.

The ObjectLinker uses the provided |token| to locate the paired ExportLink.

|token| must reference a pairable kernel object type such as |zx::channel| or |zx::eventpair|.

|token| may not reference a kernel object that is in use by this ObjectLinker.

If a link cannot be created, |error_reporter| will be used to flag an error.

The objects are linked as soon as the |Initialize()| method is called on

the links for both objects.

Defined at line 340 of file ../../src/ui/scenic/lib/utils/object_linker.h

Records