template <typename Interface>

class SynchronousInterfacePtr

Defined at line 45 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

A synchronous client interface to a remote implementation of |Interface|.

An |SynchronousInterfacePtr| implements |Interface| by proxying calls through

a |channel| to a remote implementation of |Interface|. Method calls on the

|Interface| proxy are encoded and sent through the bound channel to the

remote endpoint, which processes them. If the method has a reply (including

any empty reply), the client blocks and waits for the remote endpoint to

reply.

You need to bind the |SynchronousInterfacePtr| before calling any |Interface|

methods. There are a number of ways to bind the |SynchronousInterfacePtr|.

See |NewRequest|, |Bind|, and the |BindSync| method on |InterfaceHandle|.

This class is thread-compatible. Once bound, the |SynchronousInterfacePtr|

can be used from multiple threads simultaneously. However, the

|SynchronousInterfacePtr| does not attempt to synchronize mutating operatios,

such as |Bind| or |Unbind|.

|SynchronousInterfacePtr| does not require a |async_dispatcher_t|

implementation and does not bind to the default |async_dispatcher_t*| for the

current thread, unlike |InterfacePtr|.

See also:

* |Binding|, which is the server analog of an |SynchronousInterfacePtr|.

* |InterfacePtr|, which is an asynchronous interface to a remote

implementation.

Public Methods

void SynchronousInterfacePtr<Interface> ()

Creates an unbound |SynchronousInterfacePtr|.

Defined at line 50 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

void SynchronousInterfacePtr<Interface> (std::nullptr_t )

Defined at line 51 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

void SynchronousInterfacePtr<Interface> (const SynchronousInterfacePtr<Interface> & other)

Defined at line 53 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

SynchronousInterfacePtr<Interface> & operator= (const SynchronousInterfacePtr<Interface> & other)

Defined at line 54 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

void SynchronousInterfacePtr<Interface> (SynchronousInterfacePtr<Interface> && other)

Defined at line 56 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

SynchronousInterfacePtr<Interface> & operator= (SynchronousInterfacePtr<Interface> && other)

Defined at line 57 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

InterfaceRequest<Interface> NewRequest ()

Bind the |SynchronousInterfacePtr| to one endpoint of a newly created

channel and return the other endpoint as an |InterfaceRequest|.

Typically, the returned |InterfaceRequest| will be sent to a remote process

to be bound to an implementation of |Interface| using a |Binding| object.

After calling this method, clients can start calling methods on this

|SynchronousInterfacePtr|. However, methods that have replies will block

until the remote implementation binds the |InterfaceRequest| and replies.

# Example

Given the following interface:

interface Database {

OpenTable(request

<Table

> table);

};

The client can use the |NewRequest| method to create the |InterfaceRequest|

object needed by the |OpenTable| method:

DatabasePtr database = ...; // Connect to database.

TableSyncPtr table;

database->OpenTable(table.NewRequest());

The client can call methods on |table| immediately. Messages that have

replies will block until the Database implementation binds a Table

implementation and replies.

Defined at line 87 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

void Bind (zx::channel channel)

Binds the |SynchronousInterfacePtr| to the given |channel|.

The |SynchronousInterfacePtr| expects the remote end of the |channel| to

speak the protocol defined by |Interface|. Unlike the |Bind| overload that

takes a |InterfaceHandle| parameter, this |Bind| overload lacks type

safety.

If the |SynchronousInterfacePtr| was prevously bound to another channel,

that channel is closed. If the |channel| is invalid, then this method will

effectively unbind the |SynchronousInterfacePtr|. A more direct way to have

that effect is to call |Unbind|.

Does not require the current thread to have a default async_dispatcher_t.

Defined at line 109 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

void Bind (InterfaceHandle<Interface> handle)

Binds the |SynchronousInterfacePtr| to the given |InterfaceHandle|.

The |SynchronousInterfacePtr| expects the remote end of the |channel| to

speak the protocol defined by |Interface|. Unlike the |Bind| overload that

takes a |channel| parameter, this |Bind| overload provides type safety.

If the |SynchronousInterfacePtr| was prevously bound to another channel,

that channel is closed. If the |InterfaceHandle| is invalid, then this

method will effectively unbind the |SynchronousInterfacePtr|. A more direct

way to have that effect is to call |Unbind|.

Does not require the current thread to have a default async_dispatcher_t.

Defined at line 129 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

InterfaceHandle<Interface> Unbind ()

Unbinds the underlying channel from the |SynchronousInterfacePtr|.

The underlying channel is returned as an |InterfaceHandle|, which is safe

to transport to another thread or process.

After this method returns, a subsequent call to |Bind| is required before

calling any additional |Interface| methods.

Defined at line 138 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

bool is_bound ()

Whether this |SynchronousInterfacePtr| is currently bound to a channel.

If the |SynchronousInterfacePtr| is bound to a channel, calls to

|Interface| methods are proxied to the remote endpoint of the channel.

See also:

* |Bind|, which binds a channel to this |SynchronousInterfacePtr|.

* |Unbind|, which unbinds a channel from this |SynchronousInterfacePtr|.

Defined at line 153 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

bool operator bool ()

Whether this |SynchronousInterfacePtr| is currently bound to a channel.

See |is_bound| for details.

Defined at line 158 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

InterfaceSync * get ()

The |Interface| proxy associated with this |SynchronousInterfacePtr|.

When this |SynchronousInterfacePtr| is bound, method calls on this

|Interface| will be proxied to the remote endpoint of the connection.

Methods that expect replies will block until the

|SynchronousInterfacePtr| either receives a reply to that transaction.

When this |SynchronousInterfacePtr| is not bound, this method returns

nullptr.

The returned |Interface| is thread-compatible and can be used from any

thread.

Defined at line 172 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

InterfaceSync * operator-> ()

Defined at line 173 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

InterfaceSync & operator* ()

Defined at line 174 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h

zx::unowned_channel unowned_channel ()

The underlying channel, or null channel if not currently bound.

Defined at line 177 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/synchronous_interface_ptr.h