exchange
Low-latency exchange in C++
Loading...
Searching...
No Matches
shared_memory.hpp
Go to the documentation of this file.
1#pragma once
2#include <boost/interprocess/managed_shared_memory.hpp>
3#include <concurrent/aeron_broadcast_descriptor.h>
4#include <concurrent/aeron_rb.h>
5
6#include <string>
7
8namespace exchange::server
9{
10
15{
16 boost::interprocess::managed_shared_memory shm;
17
18 static constexpr auto defaultSegmentName{"SharedMemory"};
19 static constexpr size_t segmentSize = size_t{1024} * 1024;
20
21 bool isOwner;
22 std::string segmentName;
23
24 void deleteSegment() const;
25
26 public:
27 static constexpr auto spmcName{"SpmcQueue"};
28 static constexpr auto mpscName{"MpscQueue"};
29 static constexpr size_t spmcCapacity = size_t{256} * 1024;
30 static constexpr size_t spmcTotalObjectSize = spmcCapacity + AERON_BROADCAST_BUFFER_TRAILER_LENGTH;
31 static constexpr size_t mpscCapacity = size_t{256} * 1024;
32 static constexpr size_t mpscTotalObjectSize = mpscCapacity + AERON_RB_TRAILER_LENGTH;
33
41 explicit SharedMemory(bool isOwner, const std::string &segmentName = defaultSegmentName);
42
44
51 boost::interprocess::managed_shared_memory &get();
52};
53
54} // namespace exchange::server
boost::interprocess::managed_shared_memory & get()
Definition shared_memory.cpp:27
static constexpr size_t mpscCapacity
Definition shared_memory.hpp:31
static constexpr size_t spmcCapacity
Definition shared_memory.hpp:29
SharedMemory(bool isOwner, const std::string &segmentName=defaultSegmentName)
Definition shared_memory.cpp:12
static constexpr auto mpscName
Definition shared_memory.hpp:28
~SharedMemory()
Definition shared_memory.cpp:34
static constexpr auto spmcName
Definition shared_memory.hpp:27
static constexpr size_t mpscTotalObjectSize
Definition shared_memory.hpp:32
static constexpr size_t spmcTotalObjectSize
Definition shared_memory.hpp:30
Definition main.hpp:4