-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlock_server.h
More file actions
31 lines (25 loc) · 810 Bytes
/
lock_server.h
File metadata and controls
31 lines (25 loc) · 810 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
// this is the lock server
// the lock client has a similar interface
#ifndef lock_server_h
#define lock_server_h
#include <string>
#include <unordered_map>
#include "lock_protocol.h"
#include "lock_client.h"
#include "rpc.h"
class lock_server
{
protected:
int nacquire;
pthread_mutex_t lock_state_lock;
std::unordered_map<lock_protocol::lockid_t, pthread_mutex_t> lock_mutex;
std::unordered_map<lock_protocol::lockid_t, pthread_cond_t> lock_cv;
std::unordered_map<lock_protocol::lockid_t, bool> lock_state;
public:
lock_server();
~lock_server(){};
lock_protocol::status stat(int clt, lock_protocol::lockid_t lid, int &);
lock_protocol::status acquire(int clt, lock_protocol::lockid_t lid, int &);
lock_protocol::status release(int clt, lock_protocol::lockid_t lid, int &);
};
#endif