proxygen
|
#include <AsyncPipe.h>
Public Types | |
typedef std::unique_ptr< AsyncPipeWriter, folly::DelayedDestruction::Destructor > | UniquePtr |
Public Types inherited from folly::EventHandler | |
enum | EventFlags { NONE = 0, READ = EV_READ, WRITE = EV_WRITE, READ_WRITE = (READ | WRITE), PERSIST = EV_PERSIST } |
Static Public Member Functions | |
template<typename... Args> | |
static UniquePtr | newWriter (Args &&...args) |
Private Member Functions | |
void | handlerReady (uint16_t events) noexceptoverride |
void | handleWrite () |
void | failAllWrites (const AsyncSocketException &ex) |
~AsyncPipeWriter () override | |
Private Attributes | |
int | fd_ |
std::list< std::pair< folly::IOBufQueue, AsyncWriter::WriteCallback * > > | queue_ |
bool | closeOnEmpty_ {false} |
std::function< void(int)> | closeCb_ |
Additional Inherited Members | |
Protected Member Functions inherited from folly::AsyncWriter | |
virtual | ~AsyncWriter ()=default |
Protected Member Functions inherited from folly::DelayedDestruction | |
~DelayedDestruction () override=default | |
DelayedDestruction () | |
Protected Member Functions inherited from folly::DelayedDestructionBase | |
DelayedDestructionBase () | |
uint32_t | getDestructorGuardCount () const |
Write to a pipe in an async manner.
Definition at line 95 of file AsyncPipe.h.
typedef std:: unique_ptr<AsyncPipeWriter, folly::DelayedDestruction::Destructor> folly::AsyncPipeWriter::UniquePtr |
Definition at line 101 of file AsyncPipe.h.
|
inline |
Definition at line 108 of file AsyncPipe.h.
References fizz::detail::write().
|
inlineoverrideprivate |
Definition at line 181 of file AsyncPipe.h.
|
inline |
Returns true if the pipe is closed
Definition at line 129 of file AsyncPipe.h.
References folly::AsyncPipeReader::fd_.
void folly::AsyncPipeWriter::closeNow | ( | ) |
Close the pipe immediately, and fail all pending writes
Definition at line 187 of file AsyncPipe.cpp.
References folly::EventHandler::changeHandlerFD(), folly::AsyncPipeReader::close(), folly::AsyncPipeReader::closeCb_, folly::AsyncPipeReader::fd_, folly::AsyncSocketException::NOT_OPEN, and folly::EventHandler::unregisterHandler().
void folly::AsyncPipeWriter::closeOnEmpty | ( | ) |
Notify the pipe to close as soon as all pending writes complete
Definition at line 177 of file AsyncPipe.cpp.
References folly::EventHandler::isHandlerRegistered().
|
private |
Definition at line 205 of file AsyncPipe.cpp.
|
overrideprivatevirtualnoexcept |
handlerReady() is invoked when the handler is ready.
events | A bitset indicating the events that are ready. |
Implements folly::EventHandler.
Definition at line 217 of file AsyncPipe.cpp.
References folly::EventHandler::WRITE.
|
private |
Definition at line 223 of file AsyncPipe.cpp.
References folly::IOBufQueue::empty(), folly::AsyncPipeReader::fd_, folly::IOBufQueue::front(), folly::AsyncSocketException::INTERNAL_ERROR, folly::EventHandler::registerHandler(), folly::IOBufQueue::trimStart(), folly::EventHandler::unregisterHandler(), folly::EventHandler::WRITE, and folly::writeNoInt().
|
inline |
Return true if there are currently writes pending (eg: the pipe is blocked for writing)
Definition at line 147 of file AsyncPipe.h.
|
inlinestatic |
Definition at line 104 of file AsyncPipe.h.
Referenced by folly::TEST().
|
inline |
Set a special hook to close the socket (otherwise, will call close())
Definition at line 122 of file AsyncPipe.h.
References folly::AsyncPipeReader::closeCb_.
void folly::AsyncPipeWriter::write | ( | std::unique_ptr< folly::IOBuf > | iob, |
AsyncWriter::WriteCallback * | wcb = nullptr |
||
) |
Asynchronously write the given iobuf to this pipe, and invoke the callback on success/error.
Definition at line 145 of file AsyncPipe.cpp.
References folly::IOBufQueue::append(), folly::EventHandler::isHandlerRegistered(), folly::gen::move, folly::AsyncSocketException::NOT_OPEN, and folly::AsyncWriter::WriteCallback::writeErr().
|
inlineoverridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncWriter.
Definition at line 152 of file AsyncPipe.h.
References folly::IOBuf::wrapBuffer().
|
overridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncWriter.
Definition at line 170 of file AsyncPipe.cpp.
References folly::gen::move, and fizz::detail::write().
|
inlineoverridevirtual |
If you supply a non-null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation.
Implements folly::AsyncWriter.
Definition at line 159 of file AsyncPipe.h.
References folly::AsyncPipeReader::handlerReady(), folly::pushmi::__adl::noexcept(), folly::NONE, and uint16_t.
|
private |
Definition at line 179 of file AsyncPipe.h.
|
private |
Definition at line 178 of file AsyncPipe.h.
|
private |
Definition at line 176 of file AsyncPipe.h.
|
private |
Definition at line 177 of file AsyncPipe.h.