NCBI C++ ToolKit
|
Search Toolkit Book for SH2S_ReaderWriter
#include "ncbi_http2_session_impl.hpp"
(Private to src/connect
.)
Public Types | |
using | TUpdateResponse = function< void(CHttpHeaders::THeaders)> |
Public Member Functions | |
SH2S_ReaderWriter (TUpdateResponse update_response, shared_ptr< TH2S_ResponseQueue > response_queue, TH2S_RequestEvent request) | |
ERW_Result | Read (void *buf, size_t count, size_t *bytes_read=0) override |
Read as many as "count" bytes into a buffer pointed to by the "buf" argument. More... | |
ERW_Result | PendingCount (size_t *count) override |
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking. More... | |
ERW_Result | Write (const void *buf, size_t count, size_t *bytes_written=0) override |
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device. More... | |
ERW_Result | Flush () override |
Flush pending data (if any) down to the output device. More... | |
Public Member Functions inherited from IReaderWriter | |
virtual | ~IReaderWriter () |
Public Member Functions inherited from IReader | |
virtual ERW_Result | Pushback (const void *buf, size_t count, void *del_ptr=0) |
This method gets called by RStream buffer destructor to return buffered yet still unread (from the stream) portion of data back to the device. More... | |
virtual | ~IReader () |
Public Member Functions inherited from IWriter | |
virtual | ~IWriter () |
Private Types | |
enum | EState { eWriting , eWaiting , eReading , eEof , eError } |
Private Member Functions | |
ERW_Result | ReadFsm (function< ERW_Result()> impl) |
ERW_Result | ReadImpl (void *buf, size_t count, size_t *bytes_read) |
ERW_Result | PendingCountImpl (size_t *count) |
ERW_Result | Receive (ERW_Result(SH2S_ReaderWriter::*member)(TH2S_ResponseEvent &)) |
ERW_Result | ReceiveData (TH2S_ResponseEvent &incoming) |
ERW_Result | ReceiveResponse (TH2S_ResponseEvent &incoming) |
void | Push (TH2S_RequestEvent event) |
void | Process () |
Private Attributes | |
shared_ptr< SH2S_Io > | m_Io |
TUpdateResponse | m_UpdateResponse |
shared_ptr< TH2S_ResponseQueue > | m_ResponseQueue |
TH2S_Data | m_OutgoingData |
TH2S_Data | m_IncomingData |
EState | m_State = eWriting |
Definition at line 269 of file ncbi_http2_session_impl.hpp.
using SH2S_ReaderWriter::TUpdateResponse = function<void(CHttpHeaders::THeaders)> |
Definition at line 271 of file ncbi_http2_session_impl.hpp.
|
private |
Enumerator | |
---|---|
eWriting | |
eWaiting | |
eReading | |
eEof | |
eError |
Definition at line 289 of file ncbi_http2_session_impl.hpp.
SH2S_ReaderWriter::SH2S_ReaderWriter | ( | TUpdateResponse | update_response, |
shared_ptr< TH2S_ResponseQueue > | response_queue, | ||
TH2S_RequestEvent | request | ||
) |
Definition at line 87 of file ncbi_http2_session.cpp.
References _ASSERT, m_UpdateResponse, Process(), and Push().
|
overridevirtual |
Flush pending data (if any) down to the output device.
Implements IWriter.
Definition at line 115 of file ncbi_http2_session.cpp.
References eRW_Error, eRW_Success, eWriting, m_OutgoingData, m_ResponseQueue, m_State, Process(), and Push().
|
inlineoverridevirtual |
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking.
Return eRW_Success if the number of pending bytes has been stored at the location pointed to by "count". Return eRW_NotImplemented if the number cannot be determined. Otherwise, return other eRW_... condition to reflect the problem ("*count" does not need to be updated in the case of non-eRW_Success). Note that if reporting 0 bytes ready, the method may return either both eRW_Success and zero "*count", or return eRW_NotImplemented alone.
Implements IReader.
Definition at line 280 of file ncbi_http2_session_impl.hpp.
References count, PendingCountImpl(), and ReadFsm().
|
private |
Definition at line 181 of file ncbi_http2_session.cpp.
References count, eRW_Success, and m_IncomingData.
Referenced by PendingCount().
|
inlineprivate |
Definition at line 305 of file ncbi_http2_session_impl.hpp.
References m_Io.
Referenced by Flush(), Receive(), and SH2S_ReaderWriter().
|
inlineprivate |
Definition at line 299 of file ncbi_http2_session_impl.hpp.
References H2S_RW_TRACE, m_Io, and m_ResponseQueue.
Referenced by Flush(), ReadFsm(), and SH2S_ReaderWriter().
|
inlineoverridevirtual |
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
Always store the number of bytes actually read (0 if read none) via the pointer "bytes_read", if provided non-NULL. Return non-eRW_Success code if EOF / error condition has been encountered during the operation (some data may have been read, nevertheless, and reflected in "*bytes_read"). Special case: if "count" is passed as 0, then the value of "buf" must be ignored, and no change should be made to the state of the input device (but may return non-eRW_Success to indicate that the input device has already been in an error condition).
Implements IReader.
Definition at line 275 of file ncbi_http2_session_impl.hpp.
References buf, count, ReadFsm(), and ReadImpl().
|
private |
Definition at line 130 of file ncbi_http2_session.cpp.
References SH2S_Event< TBase >::eEof, eEof, eError, eReading, eRW_Eof, eRW_Error, eRW_Success, eWaiting, eWriting, m_IncomingData, m_ResponseQueue, m_State, Push(), Receive(), ReceiveData(), and ReceiveResponse().
Referenced by PendingCount(), and Read().
|
private |
Definition at line 165 of file ncbi_http2_session.cpp.
References buf, count, data, eRW_Success, m_IncomingData, and min().
Referenced by Read().
|
private |
Definition at line 187 of file ncbi_http2_session.cpp.
References eRW_Success, m_ResponseQueue, and Process().
Referenced by ReadFsm().
|
private |
Definition at line 203 of file ncbi_http2_session.cpp.
References _ASSERT, SH2S_Event< TBase >::eData, SH2S_Event< TBase >::eEof, eEof, SH2S_Event< TBase >::eError, eError, eReading, eRW_Eof, eRW_Error, eRW_Success, SH2S_Event< TBase >::eStart, SH2S_Event< TBase >::GetData(), SH2S_Event< TBase >::GetType(), H2S_RW_TRACE, m_IncomingData, m_ResponseQueue, and m_State.
Referenced by ReadFsm().
|
private |
Definition at line 231 of file ncbi_http2_session.cpp.
References _ASSERT, SH2S_Event< TBase >::eData, SH2S_Event< TBase >::eEof, SH2S_Event< TBase >::eError, eError, eReading, eRW_Error, eRW_Success, SH2S_Event< TBase >::eStart, eWaiting, SH2S_Event< TBase >::GetStart(), SH2S_Event< TBase >::GetType(), H2S_RW_TRACE, m_ResponseQueue, m_State, and m_UpdateResponse.
Referenced by ReadFsm().
|
overridevirtual |
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
Always store the number of bytes actually written, or 0 if "count" has been passed as 0 ("buf" must be ignored in this case), via the "bytes_written" pointer, if provided non-NULL. Note that the method can return non-eRW_Success in case of an I/O error along with indicating (some) data delivered to the output device (and reflected in "*bytes_written").
Implements IWriter.
Definition at line 99 of file ncbi_http2_session.cpp.
References buf, count, eRW_Error, eRW_Success, eWriting, m_OutgoingData, and m_State.
|
private |
Definition at line 311 of file ncbi_http2_session_impl.hpp.
Referenced by PendingCountImpl(), ReadFsm(), ReadImpl(), and ReceiveData().
|
private |
Definition at line 307 of file ncbi_http2_session_impl.hpp.
|
private |
Definition at line 310 of file ncbi_http2_session_impl.hpp.
|
private |
Definition at line 309 of file ncbi_http2_session_impl.hpp.
Referenced by Flush(), Push(), ReadFsm(), Receive(), ReceiveData(), and ReceiveResponse().
Definition at line 312 of file ncbi_http2_session_impl.hpp.
Referenced by Flush(), ReadFsm(), ReceiveData(), ReceiveResponse(), and Write().
|
private |
Definition at line 308 of file ncbi_http2_session_impl.hpp.
Referenced by ReceiveResponse(), and SH2S_ReaderWriter().