-
Notifications
You must be signed in to change notification settings - Fork 0
/
GCRegionalHashMap.h
51 lines (35 loc) · 1.16 KB
/
GCRegionalHashMap.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
41
42
43
44
45
46
47
48
49
50
51
#ifndef CPPGCPTR_GCREGIONALHASHMAP_H
#define CPPGCPTR_GCREGIONALHASHMAP_H
#include <unordered_map>
#include <shared_mutex>
#include <mutex>
#include <optional>
#include "GCStatus.h"
#include "GCPhase.h"
#include "Iterator.h"
class GCRegionalHashMap {
private:
std::unordered_map<void*, GCStatus> object_map;
std::shared_mutex map_mutex_;
public:
class RegionalHashMapIterator : public Iterator<GCStatus> {
private:
GCRegionalHashMap& regionalHashmap;
decltype(object_map)::iterator it;
bool iterate_begun;
public:
explicit RegionalHashMapIterator(GCRegionalHashMap&);
~RegionalHashMapIterator() override;
GCStatus current() const override;
bool MoveNext() override;
void* getCurrentAddress() const;
void setCurrentMarkState(MarkState);
};
GCRegionalHashMap();
bool mark(void* object_addr, size_t object_size, MarkState markState,
bool overwrite = false, bool emplace_if_not_exist = true);
std::optional<MarkState> getMarkState(void* object_addr);
RegionalHashMapIterator getIterator();
void clear();
};
#endif //CPPGCPTR_GCREGIONALHASHMAP_H