Fixes
This commit is contained in:
@ -46,6 +46,18 @@ namespace IACore
|
|||||||
// All of the data in ring buffer will be stored as packets
|
// All of the data in ring buffer will be stored as packets
|
||||||
struct PacketHeader
|
struct PacketHeader
|
||||||
{
|
{
|
||||||
|
PacketHeader() : ID(0), PayloadSize(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketHeader(IN UINT16 id) : ID(id), PayloadSize(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketHeader(IN UINT16 id, IN UINT16 payloadSize) : ID(id), PayloadSize(payloadSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UINT16 ID{};
|
UINT16 ID{};
|
||||||
UINT16 PayloadSize{};
|
UINT16 PayloadSize{};
|
||||||
};
|
};
|
||||||
@ -145,9 +157,7 @@ namespace IACore
|
|||||||
UINT32 write = m_controlBlock->Producer.WriteOffset.load(std::memory_order_relaxed);
|
UINT32 write = m_controlBlock->Producer.WriteOffset.load(std::memory_order_relaxed);
|
||||||
UINT32 cap = m_capacity;
|
UINT32 cap = m_capacity;
|
||||||
|
|
||||||
UINT32 freeSpace = (read <= write)
|
UINT32 freeSpace = (read <= write) ? (m_capacity - write) + read : (read - write);
|
||||||
? (m_capacity - write) + read
|
|
||||||
: (read - write);
|
|
||||||
|
|
||||||
// Ensure to always leave 1 byte empty to prevent Read == Write ambiguity (Wait-Free Ring Buffer standard)
|
// Ensure to always leave 1 byte empty to prevent Read == Write ambiguity (Wait-Free Ring Buffer standard)
|
||||||
if (freeSpace <= totalSize)
|
if (freeSpace <= totalSize)
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
namespace IACore
|
namespace IACore
|
||||||
{
|
{
|
||||||
|
using IPC_PacketHeader = RingBufferView::PacketHeader;
|
||||||
|
|
||||||
struct alignas(64) IPC_SharedMemoryLayout
|
struct alignas(64) IPC_SharedMemoryLayout
|
||||||
{
|
{
|
||||||
// =========================================================
|
// =========================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user