-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem.hpp
More file actions
34 lines (30 loc) · 826 Bytes
/
mem.hpp
File metadata and controls
34 lines (30 loc) · 826 Bytes
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
#include <string>
#include <atomic>
#include <utility>
#include <vector>
#include <unordered_map>
#define EMPTY 0
#define COLLECTED_BY_OTHER 1
#define ALL_COLLECTED 2
//class MemTotalEnergy {
//public:
// MemTotalEnergy(std::string userId, int totalEnergy) {
// userId_ = std::move(userId);
// totalEnergy_ = totalEnergy;
// }
//
// std::string userId_;
// std::atomic_uint32_t totalEnergy_{};
//
// MemTotalEnergy() = default;
//};
class MemToCollect {
public:
std::string user_id_;
std::uint8_t status_ = EMPTY;//0:EMPTY, 1:COLLECTED_BY_OTHER, 2:ALL_COLLECTED;
std::uint32_t to_collect_energy_;
bool modified_ = false;
std::mutex mutex;
};
MemToCollect *memToCollects[100 * 10000 + 1] = {nullptr};
std::unordered_map<std::string, std::atomic_uint32_t> memTotalEnergyMap;