proxygen
|
#include <AsyncSocketHandler.h>
Classes | |
class | WriteCallback |
Public Member Functions | |
AsyncSocketHandler (std::shared_ptr< folly::AsyncTransportWrapper > socket) | |
AsyncSocketHandler (AsyncSocketHandler &&)=default | |
~AsyncSocketHandler () override | |
void | attachReadCallback () |
void | detachReadCallback () |
void | attachEventBase (folly::EventBase *eventBase) |
void | detachEventBase () |
void | transportActive (Context *ctx) override |
void | transportInactive (Context *ctx) override |
void | detachPipeline (Context *) override |
folly::Future< folly::Unit > | write (Context *ctx, std::unique_ptr< folly::IOBuf > buf) override |
folly::Future< folly::Unit > | writeException (Context *ctx, folly::exception_wrapper) override |
folly::Future< folly::Unit > | close (Context *ctx) override |
void | readEOF (Context *ctx) override |
void | getReadBuffer (void **bufReturn, size_t *lenReturn) override |
void | readDataAvailable (size_t len) noexceptoverride |
void | readEOF () noexceptoverride |
void | readErr (const folly::AsyncSocketException &ex) noexceptoverride |
![]() | |
void | read (Context *ctx, R msg) override |
folly::Future< folly::Unit > | write (Context *ctx, W msg) override |
![]() | |
~Handler () override=default | |
virtual void | read (Context *ctx, Rmsg)=0 |
virtual void | readEOF (Context *ctx) |
virtual void | readException (Context *ctx, folly::exception_wrapper e) |
virtual void | transportActive (Context *ctx) |
virtual void | transportInactive (Context *ctx) |
virtual folly::Future< folly::Unit > | write (Context *ctx, Wmsg)=0 |
virtual folly::Future< folly::Unit > | writeException (Context *ctx, folly::exception_wrapper e) |
virtual folly::Future< folly::Unit > | close (Context *ctx) |
![]() | |
virtual | ~HandlerBase ()=default |
virtual void | attachPipeline (HandlerContext< R, W > *) |
virtual void | detachPipeline (HandlerContext< R, W > *) |
HandlerContext< R, W > * | getContext () |
![]() | |
virtual | ~ReadCallback ()=default |
virtual bool | isBufferMovable () noexcept |
virtual size_t | maxBufferSize () const |
virtual void | readBufferAvailable (std::unique_ptr< IOBuf >) noexcept |
Private Member Functions | |
void | refreshTimeout () |
folly::Future< folly::Unit > | shutdown (Context *ctx, bool closeWithReset) |
Private Attributes | |
folly::IOBufQueue | bufQueue_ {folly::IOBufQueue::cacheChainLength()} |
std::shared_ptr< folly::AsyncTransportWrapper > | socket_ {nullptr} |
bool | firedInactive_ {false} |
bool | pipelineDeleted_ {false} |
Additional Inherited Members | |
![]() | |
typedef Handler< R, R, W, W >::Context | Context |
![]() | |
typedef R | rin |
typedef R | rout |
typedef W | win |
typedef W | wout |
typedef HandlerContext< R, W > | Context |
![]() | |
static const HandlerDir | dir |
Definition at line 29 of file AsyncSocketHandler.h.
|
inlineexplicit |
Definition at line 33 of file AsyncSocketHandler.h.
|
default |
|
inlineoverride |
Definition at line 39 of file AsyncSocketHandler.h.
References detachReadCallback(), folly::gen::move, s, and socket_.
|
inline |
Definition at line 68 of file AsyncSocketHandler.h.
References socket_.
|
inline |
Definition at line 53 of file AsyncSocketHandler.h.
References socket_.
Referenced by transportActive().
|
inlineoverride |
Definition at line 125 of file AsyncSocketHandler.h.
References folly::isSet(), folly::makeFuture(), shutdown(), socket_, and folly::WRITE_SHUTDOWN.
|
inline |
Definition at line 74 of file AsyncSocketHandler.h.
References detachReadCallback(), and socket_.
|
inlineoverride |
Definition at line 95 of file AsyncSocketHandler.h.
References detachReadCallback().
|
inline |
Definition at line 57 of file AsyncSocketHandler.h.
References firedInactive_, wangle::HandlerBase< HandlerContext< R, W > >::getContext(), and socket_.
Referenced by detachEventBase(), detachPipeline(), shutdown(), transportInactive(), and ~AsyncSocketHandler().
|
inlineoverridevirtual |
When data becomes available, getReadBuffer() will be invoked to get the buffer into which data should be read.
This method allows the ReadCallback to delay buffer allocation until data becomes available. This allows applications to manage large numbers of idle connections, without having to maintain a separate read buffer for each idle connection.
It is possible that in some cases, getReadBuffer() may be called multiple times before readDataAvailable() is invoked. In this case, the data will be written to the buffer returned from the most recent call to readDataAvailable(). If the previous calls to readDataAvailable() returned different buffers, the ReadCallback is responsible for ensuring that they are not leaked.
If getReadBuffer() throws an exception, returns a nullptr buffer, or returns a 0 length, the ReadCallback will be uninstalled and its readError() method will be invoked.
getReadBuffer() is not allowed to change the transport state before it returns. (For example, it should never uninstall the read callback, or set a different read callback.)
bufReturn | getReadBuffer() should update *bufReturn to contain the address of the read buffer. This parameter will never be nullptr. |
lenReturn | getReadBuffer() should update *lenReturn to contain the maximum number of bytes that may be written to the read buffer. This parameter will never be nullptr. |
Implements folly::AsyncReader::ReadCallback.
Definition at line 142 of file AsyncSocketHandler.h.
References bufQueue_, wangle::HandlerBase< HandlerContext< R, W > >::getContext(), wangle::HandlerContext< In, Out >::getReadBufferSettings(), and folly::IOBufQueue::preallocate().
|
inlineoverridevirtualnoexcept |
readDataAvailable() will be invoked when data has been successfully read into the buffer returned by the last call to getReadBuffer().
The read callback remains installed after readDataAvailable() returns. It must be explicitly uninstalled to stop receiving read events. getReadBuffer() will be called at least once before each call to readDataAvailable(). getReadBuffer() will also be called before any call to readEOF().
len | The number of bytes placed in the buffer. |
Implements folly::AsyncReader::ReadCallback.
Definition at line 151 of file AsyncSocketHandler.h.
References bufQueue_, wangle::HandlerContext< In, Out >::fireRead(), wangle::HandlerBase< HandlerContext< R, W > >::getContext(), folly::IOBufQueue::postallocate(), and refreshTimeout().
|
inlineoverride |
Definition at line 138 of file AsyncSocketHandler.h.
|
inlineoverridevirtualnoexcept |
readEOF() will be invoked when the transport is closed.
The read callback will be automatically uninstalled immediately before readEOF() is invoked.
Implements folly::AsyncReader::ReadCallback.
Definition at line 157 of file AsyncSocketHandler.h.
References wangle::HandlerContext< In, Out >::fireReadEOF(), and wangle::HandlerBase< HandlerContext< R, W > >::getContext().
|
inlineoverridevirtualnoexcept |
readError() will be invoked if an error occurs reading from the transport.
The read callback will be automatically uninstalled immediately before readError() is invoked.
ex | An exception describing the error that occurred. |
Implements folly::AsyncReader::ReadCallback.
Definition at line 161 of file AsyncSocketHandler.h.
References wangle::HandlerContext< In, Out >::fireReadException(), and wangle::HandlerBase< HandlerContext< R, W > >::getContext().
|
inlineprivate |
Definition at line 168 of file AsyncSocketHandler.h.
References wangle::HandlerBase< HandlerContext< R, W > >::getContext(), wangle::HandlerContext< In, Out >::getPipeline(), wangle::PipelineBase::getPipelineManager(), and wangle::PipelineManager::refreshTimeout().
Referenced by readDataAvailable(), and write().
|
inlineprivate |
Definition at line 175 of file AsyncSocketHandler.h.
References detachReadCallback(), folly::makeFuture(), pipelineDeleted_, and socket_.
Referenced by close(), and writeException().
|
inlineoverride |
Definition at line 81 of file AsyncSocketHandler.h.
References attachReadCallback(), firedInactive_, and socket_.
|
inlineoverride |
Definition at line 88 of file AsyncSocketHandler.h.
References detachReadCallback().
|
inlineoverride |
Definition at line 99 of file AsyncSocketHandler.h.
References folly::makeFuture(), folly::gen::move, refreshTimeout(), socket_, and UNLIKELY.
|
inlineoverride |
Definition at line 120 of file AsyncSocketHandler.h.
References shutdown().
|
private |
Definition at line 209 of file AsyncSocketHandler.h.
Referenced by getReadBuffer(), and readDataAvailable().
|
private |
Definition at line 211 of file AsyncSocketHandler.h.
Referenced by detachReadCallback(), and transportActive().
|
private |
Definition at line 212 of file AsyncSocketHandler.h.
Referenced by shutdown().
|
private |
Definition at line 210 of file AsyncSocketHandler.h.
Referenced by attachEventBase(), attachReadCallback(), close(), detachEventBase(), detachReadCallback(), shutdown(), transportActive(), write(), and ~AsyncSocketHandler().