![]() |
Bitcoin Core 31.0.0
P2P Digital Currency
|
Unidirectional bytes or CNetMessage queue (FIFO). More...
#include <net.h>
Public Member Functions | |
| ssize_t | GetBytes (void *buf, size_t len, int flags=0) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Get bytes and remove them from the pipe. | |
| std::optional< CNetMessage > | GetNetMsg () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Deserialize a CNetMessage and remove it from the pipe. | |
| void | PushBytes (const void *buf, size_t len) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Push bytes to the pipe. | |
| template<typename... Args> | |
| void | PushNetMsg (const std::string &type, Args &&... payload) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
| Construct and push CNetMessage to the pipe. | |
| void | Eof () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Signal end-of-file on the receiving end (GetBytes() or GetNetMsg()). | |
Private Member Functions | |
| void | WaitForDataOrEof (UniqueLock< Mutex > &lock) EXCLUSIVE_LOCKS_REQUIRED(m_mutex) |
| Return when there is some data to read or EOF has been signaled. | |
| std::vector< uint8_t > m_data | GUARDED_BY (m_mutex) |
| bool m_eof | GUARDED_BY (m_mutex) |
Private Attributes | |
| Mutex | m_mutex |
| std::condition_variable | m_cond |
Unidirectional bytes or CNetMessage queue (FIFO).
| void DynSock::Pipe::Eof | ( | ) |
Signal end-of-file on the receiving end (GetBytes() or GetNetMsg()).
Definition at line 332 of file net.cpp.
Get bytes and remove them from the pipe.
| [in] | buf | Destination to write bytes to. |
| [in] | len | Write up to this number of bytes. |
| [in] | flags | Same as the flags of recv(2). Just MSG_PEEK is honored. |
buf. 0 if Eof() has been called. If no bytes are available then -1 is returned and errno is set to EAGAIN. Definition at line 264 of file net.cpp.
| std::optional< CNetMessage > DynSock::Pipe::GetNetMsg | ( | ) |
Deserialize a CNetMessage and remove it from the pipe.
If not enough bytes are available then the function will wait. If parsing fails or EOF is signaled to the pipe, then std::nullopt is returned.
Definition at line 286 of file net.cpp.
| void DynSock::Pipe::PushNetMsg | ( | const std::string & | type, |
| Args &&... | payload ) |
Construct and push CNetMessage to the pipe.
Definition at line 363 of file net.h.
|
private |
Return when there is some data to read or EOF has been signaled.
| [in,out] | lock | Unique lock that must have been derived from m_mutex by WAIT_LOCK(m_mutex, lock). |
Definition at line 339 of file net.cpp.