8#ifndef FACEBOOK_NETWORK_PACKAGED_SOCKET_H
9#define FACEBOOK_NETWORK_PACKAGED_SOCKET_H
67 inline const void*
data()
const;
91 inline size_t size()
const;
186 inline size_t size()
const;
194 static constexpr uint64_t
oceanTag();
208 static_assert(
sizeof(
PackageHeader) ==
sizeof(uint64_t) * 3,
"Invalid header!");
274 return memory_.constdata<uint8_t>();
281 return memory_.data<uint8_t>();
359 return sizeof(
MessageId) +
sizeof(
unsigned int) +
sizeof(
unsigned int) +
sizeof(
unsigned int) +
sizeof(
unsigned int);
364 return 1024 * 1024 * 1024;
static constexpr unsigned long long string2tag(const char tagString[8])
Converts a string with exactly eight characters to a unique tag value.
Definition Bitstream.h:454
This class implements an object able to allocate memory.
Definition base/Memory.h:22
This class implements a memory block.
Definition PackagedSocket.h:42
MemoryBlock(const size_t size)
Creates a new memory block.
void resetOffset()
Resets the memory offset location back to the start.
Definition PackagedSocket.h:305
size_t size() const
Returns the overall number of bytes in the memory block.
Definition PackagedSocket.h:300
MemoryBlock(const void *data, const size_t size)
Creates a new memory block and copied memory from source data.
Memory memory_
The actual memory, can be larger than 'size_'.
Definition PackagedSocket.h:125
void moveOffset(const size_t delta)
Moves the offset within the memory block.
Definition PackagedSocket.h:310
const void * offsetData() const
Returns the pointer to the offset location within the memory block.
Definition PackagedSocket.h:284
MemoryBlock()=default
Default constructor creating an empty memory block.
void resize(const size_t size)
Resizes the memory block.
bool isValid() const
Returns whether this memory block holds memory.
Definition PackagedSocket.h:325
size_t size_
The actual size of the usable memory, in bytes.
Definition PackagedSocket.h:128
const void * data() const
Returns the pointer to the start of the memory block.
Definition PackagedSocket.h:270
size_t remainingBytes() const
Returns the number of remaining bytes.
Definition PackagedSocket.h:319
size_t offset_
The offset within the memory.
Definition PackagedSocket.h:131
static bool extractNextPackage(MemoryBlockQueue &sourceQueue, MemoryBlock &targetMemory)
Extracts a memory block from a queue with memory block.
PackagedSocket()
Creates a new packaged socket.
std::queue< MemoryBlock > MemoryBlockQueue
Definition of a queue holding memory blocks.
Definition PackagedSocket.h:137
static constexpr size_t packageManagmentHeaderSize()
Returns the size of the package management header in bytes.
Definition PackagedSocket.h:357
static constexpr MessageId invalidMessageId()
Returns an invalid message id.
Definition PackagedSocket.h:352
uint32_t MessageId
Definition of a message id.
Definition PackagedSocket.h:215
static constexpr size_t maximalPackagedMessageSize()
Returns the maximal size of a packaged message.
Definition PackagedSocket.h:362
Socket()
Creates a new socket object.
Namespace of the Network library.
Definition Address4.h:18
The namespace covering the entire Ocean framework.
Definition Accessor.h:15