-
Notifications
You must be signed in to change notification settings - Fork 1
/
coarse.h
45 lines (36 loc) · 993 Bytes
/
coarse.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
#ifndef COARSE_H
#define COARSE_H
#include "sequential.h"
#include <mutex>
using namespace std;
class Coarse: public HashTable {
private:
Sequential seq;
mutex lock;
public:
Coarse(bool toresize = true) : seq(toresize) {}
uint32_t get(uint32_t key) {
lock_guard<mutex> lock_g(lock);
uint32_t val = seq.get(key);
return val;
}
void put(uint32_t key, uint32_t val) {
lock_guard<mutex> lock_g(lock);
seq.put(key, val);
}
bool hasKey(uint32_t key) {
lock_guard<mutex> lock_g(lock);
bool result = seq.hasKey(key);
return result;
}
uint32_t size() {
lock_guard<mutex> lock_g(lock);
uint32_t result = seq.size();
return result;
}
bool isEmpty() {
lock_guard<mutex> lock_g(lock);
return seq.size() == 0;
}
};
#endif