RDFS
The Rice Comp413 2017 class' continuation on the work of the 2016 RDFS.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
zk_lock.h
1 // Copyright 2017 Rice University, COMP 413 2017
2 
3 #ifndef ZKWRAPPER_INCLUDE_ZK_LOCK_H_
4 #define ZKWRAPPER_INCLUDE_ZK_LOCK_H_
5 
6 #include <easylogging++.h>
7 #include <algorithm>
8 #include <thread> // std::thread, std::this_thread::yield
9 #include <mutex> // std::mutex, std::unique_lock
10 #include <condition_variable> // std::condition_variable
11 #include <string>
12 #include <sstream>
13 #include <vector>
14 #include <boost/algorithm/string.hpp>
15 #include "zkwrapper.h"
16 
21 class ZKLock {
22  public:
33  ZKLock(ZKWrapper &zkWrapper, std::string path) :
34  zkWrapper(zkWrapper), path_to_lock(path) {}
35 
40  int lock();
41 
45  int unlock();
46 
47  private:
48  ZKWrapper zkWrapper;
49 
50  std::string path_to_lock;
51 
52  static const char lock_path[];
53 
54  std::string locknode_with_seq;
55 
56  static const std::string CLASS_NAME;
57 };
58 #endif // ZKWRAPPER_INCLUDE_ZK_LOCK_H_
int lock()
Definition: zk_lock.cc:7
Definition: zkwrapper.h:62
int unlock()
Definition: zk_lock.cc:97
ZKLock(ZKWrapper &zkWrapper, std::string path)
Definition: zk_lock.h:33
Definition: zk_lock.h:21