Mir
Classes | Public Member Functions | List of all members
mir::client::rpc::StreamTransport Class Referenceabstract

Responsible for shuttling bytes to and from the server. More...

#include <stream_transport.h>

Inheritance diagram for mir::client::rpc::StreamTransport:
[legend]

Classes

class  Observer
 Observer of IO status. More...
 

Public Member Functions

virtual ~StreamTransport ()=default
 
 StreamTransport ()=default
 
 StreamTransport (StreamTransport const &)=delete
 
StreamTransportoperator= (StreamTransport const &)=delete
 
virtual void register_observer (std::shared_ptr< Observer > const &observer)=0
 Register an IO observer. More...
 
virtual void unregister_observer (std::shared_ptr< Observer > const &observer)=0
 Unregister a previously-registered observer. More...
 
virtual void receive_data (void *buffer, size_t bytes_requested)=0
 Read data from the server. More...
 
virtual void receive_data (void *buffer, size_t bytes_requested, std::vector< Fd > &fds)=0
 Read data and file descriptors from the server. More...
 
virtual void send_message (std::vector< uint8_t > const &buffer, std::vector< Fd > const &fds)=0
 Write message to the server. More...
 
- Public Member Functions inherited from mir::dispatch::Dispatchable
 Dispatchable ()=default
 
virtual ~Dispatchable ()=default
 
Dispatchableoperator= (Dispatchable const &)=delete
 
 Dispatchable (Dispatchable const &)=delete
 
virtual Fd watch_fd () const =0
 Get a poll()able file descriptor. More...
 
virtual bool dispatch (FdEvents events)=0
 Dispatch one pending event. More...
 
virtual FdEvents relevant_events () const =0
 The set of file-descriptor events this Dispatchable handles. More...
 

Detailed Description

Responsible for shuttling bytes to and from the server.

This is a transport providing stream semantics. It does not preserve message boundaries, writes from the remote end are not guaranteed to become available for reading atomically, and local writes are not guaranteed to become available for reading at the remote end atomically.

In practice reads and writes of “small size” will be atomic. See your kernel source tree for a definition of “small size” :).

As it does not preserve message boundaries, partial reads do not discard any unread data waiting for reading. This applies for both binary data and file descriptors.

Note
It is safe to call a read and a write method simultaneously from different threads. Multiple threads calling the same function need synchronisation.

Constructor & Destructor Documentation

virtual mir::client::rpc::StreamTransport::~StreamTransport ( )
virtualdefault
Note
Upon completion of the destructor it is guaranteed that no methods will be called by the StreamTransport on any Observer that had been registered.
mir::client::rpc::StreamTransport::StreamTransport ( )
default
mir::client::rpc::StreamTransport::StreamTransport ( StreamTransport const &  )
delete

Member Function Documentation

StreamTransport& mir::client::rpc::StreamTransport::operator= ( StreamTransport const &  )
delete
virtual void mir::client::rpc::StreamTransport::receive_data ( void *  buffer,
size_t  bytes_requested 
)
pure virtual

Read data from the server.

Parameters
[out]bufferBuffer to read into
[in]bytes_requestedNumber of bytes to read
Exceptions
Astd::runtime_error if it is not possible to read read_bytes bytes from the server.
Note
This provides stream semantics - message boundaries are not preserved.

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::receive_data ( void *  buffer,
size_t  bytes_requested,
std::vector< Fd > &  fds 
)
pure virtual

Read data and file descriptors from the server.

Parameters
[out]bufferBuffer to read into
[in]bytes_requestedNumber of bytes to read
[in,out]fdsFile descriptors received in this read. The value of fds.size() determines the number of file descriptors to receive.
Exceptions
Astd::runtime_error if it is not possible to read read_bytes bytes from the server or if it is not possible to read fds.size() file descriptors from the server.
Note
This provides stream semantics - message boundaries are not preserved.

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::register_observer ( std::shared_ptr< Observer > const &  observer)
pure virtual

Register an IO observer.

Parameters
[in]observer

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::send_message ( std::vector< uint8_t > const &  buffer,
std::vector< Fd > const &  fds 
)
pure virtual

Write message to the server.

Parameters
[in]bufferData to send
[in]fdsFds to send
Exceptions
Astd::runtime_error if it is not possible to write the full contents of buffer to the server.

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::unregister_observer ( std::shared_ptr< Observer > const &  observer)
pure virtual

Unregister a previously-registered observer.

Parameters
[in]observer.This object must be managed by one of the shared_ptrs previously registered via register_observer().

Implemented in mir::client::rpc::StreamSocketTransport.


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

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016