-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharedMem.h
40 lines (28 loc) · 984 Bytes
/
SharedMem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
// server is defined for char * only
#undef UNICODE
static_assert(_WIN32,"This class compiles under Windows only (due to shared memory specifics)");
#include <windows.h>
#include <string>
#include "Allocator.h"
/**
Allocator for a big chunk of memory in shared memory. It is expected to be able to
allocate more than simple malloc() as in Allocator.
This class is available only in Windows!
*/
class SharedMem : public Allocator {
private:
/** Mapping */
HANDLE mapping_ = NULL;
/** Init mapping, buffer is nullptr in case of failure */
bool initMapping(const char* pname, const size_t psize, const bool clearmemory);
/** Close mapping */
void closeMapping();
public:
/** Default constructor */
SharedMem() = default;
/** Initialise */
virtual bool init(const char* pname, const size_t psize, const bool clearMemory);
/** Destructor */
~SharedMem();
};