Collage
1.7.0
High-performance C++ library for developing object-oriented distributed applications.
|
A proxy connection buffering outgoing data into a memory buffer. More...
#include <bufferConnection.h>
Public Member Functions | |
CO_API | BufferConnection () |
Construct a new buffer connection. More... | |
virtual CO_API | ~BufferConnection () |
Destruct this buffer connection. More... | |
CO_API void | sendBuffer (ConnectionPtr connection) |
Flush the accumulated data, sending it to the given connection. More... | |
CO_API const lunchbox::Bufferb & | getBuffer () const |
CO_API lunchbox::Bufferb & | getBuffer () |
CO_API uint64_t | getSize () const |
Public Member Functions inherited from co::Connection | |
CO_API State | getState () const |
bool | isClosed () const |
bool | isClosing () const |
bool | isConnected () const |
bool | isListening () const |
CO_API bool | isMulticast () const |
CO_API ConstConnectionDescriptionPtr | getDescription () const |
bool | operator== (const Connection &rhs) const |
virtual bool | connect () |
Connect to the remote peer. More... | |
virtual bool | listen () |
Put the connection into the listening state. More... | |
virtual void | close () |
Close a connected or listening connection. More... | |
void | addListener (ConnectionListener *listener) |
void | removeListener (ConnectionListener *listener) |
virtual void | acceptNB () |
Start an accept operation. More... | |
virtual ConnectionPtr | acceptSync () |
Complete an accept operation. More... | |
CO_API void | recvNB (BufferPtr buffer, const uint64_t bytes) |
Start a read operation on the connection. More... | |
CO_API bool | recvSync (BufferPtr &buffer, const bool block=true) |
Finish reading data from the connection. More... | |
BufferPtr | resetRecvData () |
CO_API bool | send (const void *buffer, const uint64_t bytes, const bool isLocked=false) |
Send data using the connection. More... | |
CO_API void | lockSend () const |
Lock the connection, no other thread can send data. More... | |
CO_API void | unlockSend () const |
Unlock the connection. More... | |
virtual void | finish () |
Protected Member Functions | |
void | readNB (void *, const uint64_t) override |
Start a read operation on the connection. More... | |
int64_t | readSync (void *, const uint64_t, const bool) override |
Finish reading data from the connection. More... | |
CO_API int64_t | write (const void *buffer, const uint64_t bytes) override |
Write data to the connection. More... | |
Notifier | getNotifier () const override |
Protected Member Functions inherited from co::Connection | |
Connection () | |
Construct a new connection. More... | |
virtual | ~Connection () |
Destruct this connection. More... | |
CO_API void | _setDescription (ConnectionDescriptionPtr description) |
CO_API void | _setState (const State state) |
CO_API ConnectionDescriptionPtr | _getDescription () |
Additional Inherited Members | |
Public Types inherited from co::Connection | |
enum | State { STATE_CLOSED, STATE_CONNECTING, STATE_CONNECTED, STATE_LISTENING, STATE_CLOSING } |
The current state of the Connection. More... | |
typedef int | Notifier |
The Notifier used by the ConnectionSet to detect readiness of a Connection. | |
Static Public Member Functions inherited from co::Connection | |
static CO_API ConnectionPtr | create (ConnectionDescriptionPtr desc) |
Create a new connection. More... | |
Protected Types inherited from co::Connection | |
enum | ReadStatus { READ_TIMEOUT = -2, READ_ERROR = -1 } |
< error codes for readSync() | |
A proxy connection buffering outgoing data into a memory buffer.
Definition at line 34 of file bufferConnection.h.
CO_API co::BufferConnection::BufferConnection | ( | ) |
Construct a new buffer connection.
|
virtual |
Destruct this buffer connection.
CO_API const lunchbox::Bufferb& co::BufferConnection::getBuffer | ( | ) | const |
CO_API lunchbox::Bufferb& co::BufferConnection::getBuffer | ( | ) |
|
inlineoverrideprotectedvirtual |
Implements co::Connection.
Definition at line 69 of file bufferConnection.h.
CO_API uint64_t co::BufferConnection::getSize | ( | ) | const |
|
inlineoverrideprotectedvirtual |
Start a read operation on the connection.
This method is the low-level counterpart used by recvNB(), implemented by the concrete connection.
This function returns immediately. The operation's Notifier will signal data availability, upon which readSync() is used to finish the operation.
buffer | the buffer receiving the data. |
bytes | the number of bytes to read. |
Implements co::Connection.
Definition at line 61 of file bufferConnection.h.
|
inlineoverrideprotectedvirtual |
Finish reading data from the connection.
This method is the low-level counterpart used by recvSync(), implemented by the concrete connection. It may return with a partial read.
buffer | the buffer receiving the data. |
bytes | the number of bytes to read. |
block | internal WAR parameter, ignore it in the implementation unless you know exactly why not. |
Implements co::Connection.
Definition at line 62 of file bufferConnection.h.
CO_API void co::BufferConnection::sendBuffer | ( | ConnectionPtr | connection | ) |
Flush the accumulated data, sending it to the given connection.
|
overrideprotectedvirtual |
Write data to the connection.
This method is the low-level counterpart used by send(), implemented by the concrete connection. It may return with a partial write.
buffer | the buffer containing the message. |
bytes | the number of bytes to write. |
Implements co::Connection.