This repository was archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_map.h
More file actions
51 lines (39 loc) · 1.25 KB
/
shared_map.h
File metadata and controls
51 lines (39 loc) · 1.25 KB
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
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "shared_utils.h"
typedef basic_string<char, std::char_traits<char>, CharAllocator> ShmemString;
typedef std::pair<const ShmemBuffer, ShmemBuffer> PairType;
typedef allocator<PairType, managed_shared_memory::segment_manager> PairAllocator;
typedef map<ShmemBuffer, ShmemBuffer, std::less<ShmemBuffer>, PairAllocator> ShmemMap;
class SharedMap : public Napi::ObjectWrap<SharedMap>
{
class ShmemObject
{
public:
ShmemObject() {}
boost::interprocess::interprocess_mutex mutex;
};
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
public:
SharedMap(const Napi::CallbackInfo &info);
~SharedMap();
private:
//methods
void insert(const Napi::CallbackInfo &info);
Napi::Value at(const Napi::CallbackInfo &info);
void erase(const Napi::CallbackInfo &info);
Napi::Value empty(const Napi::CallbackInfo &info);
void clear(const Napi::CallbackInfo &info);
private:
// variables
static Napi::FunctionReference constructor;
managed_mapped_file *pSegment;
ShmemMap *pMap;
ShmemObject *pObj;
// properties
std::string name;
Napi::Value getName(const Napi::CallbackInfo &info);
void setName(const Napi::CallbackInfo &info, const Napi::Value &value);
Napi::Value getValue(const Napi::CallbackInfo &info);
// utils
};