-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlock_server.h
42 lines (27 loc) · 883 Bytes
/
lock_server.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
// this is the lock server
// the lock client has a similar interface
#ifndef lock_server_h
#define lock_server_h
#include <string>
#include "lock_protocol.h"
#include "lock_client.h"
#include "rpc.h"
#include <map>
#include <pthread.h>
class lock_server {
protected:
int nacquire;
enum lock_state { LOCKFREE, LOCKED };
typedef int l_state;
typedef std::map<lock_protocol::lockid_t, l_state> TLockStateMap;
TLockStateMap tLockMap;
pthread_mutex_t lmap_mutex;
pthread_cond_t lmap_state_cv;
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