-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbworker.hpp
52 lines (46 loc) · 1.3 KB
/
dbworker.hpp
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
52
#ifndef _dbworker_hpp
#define _dbworker_hpp
#include <cassert>
#include <stdexcept>
#include <iostream>
#include <unistd.h>
#include <pthread.h>
#include "common.hpp"
#include "transaction.hpp"
#include "BPlusTree.hpp"
using namespace std;
class dbcoordinator;
class ExcuteTransaction;
class dbworker {
private:
partition p;
pthread_mutex_t buf_mutex;
pthread_mutex_t work_mutex;
pthread_cond_t work_cv;
pthread_cond_t buf_cv;
TransactionReq* trans_req;
/*B+ tree of the partitioned key value store*/
BPlusTree partitionedDB;
bool isComplete;
TransactionRsp trans_rsp;
public:
friend class dbcoordinator;
friend class ExcuteTransaction;
dbworker();
/*work cv, coordinator must signal work cv to wake up the worker*/
/*map that store the result of get and get_range for coordinator*/
//map<string, xmlrpc_c::value> buf;
/*bool that store the result of put*/
//bool* result;
/*condition variable to wake up worker or inform coordinator*/
/*Key range the worker is responsible for*/
//Key lower_bound, upper_bound;
/*
dbworker();
void put(Key key, Value value);
map<string, xmlrpc_c::value> get(Key key);
map<string, xmlrpc_c::value> get_range(Key key1, Key key2);
*/
static void *worker_routine(void *args) ;
};
#endif