CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fd_refcount_mgr.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_FD_REFCOUNT_MGR_H_
6 #define CVMFS_FD_REFCOUNT_MGR_H_
7 
8 #include <string>
9 
10 #include "cache.h"
11 #include "smallhash.h"
12 
13 
14 // for map of file descriptors; as in kvstore.cc
15 static inline uint32_t hasher_any(const shash::Any &key) {
16  // We'll just do the same thing as hasher_md5, since every hash is at
17  // least as large.
18  return *const_cast<uint32_t *>(
19  reinterpret_cast<const uint32_t *>(key.digest) + 1);
20 }
21 static inline uint32_t hasher_int(const int &key) {
22  return MurmurHash2(&key, sizeof(key), 0x07387a4f);
23 }
24 
26  public:
30  struct FdRefcountInfo {
31  int refcount;
33 
35  };
36 
37  FdRefcountMgr();
38 
40 
42  const SmallHashDynamic<int, FdRefcountInfo> &map_refcount,
43  const SmallHashDynamic<shash::Any, int> &map_fd);
44 
45  void AssignFrom(FdRefcountMgr *other);
46 
48 
50 
51  int Open(const shash::Any id, const std::string& path);
52 
53  int Close(int fd);
54 
55  int Dup(int fd);
56 
58 
59  private:
72  pthread_mutex_t *lock_cache_refcount_;
73 };
74 
75 #endif // CVMFS_FD_REFCOUNT_MGR_H_
int Dup(int fd)
SmallHashDynamic< int, FdRefcountInfo > * GetRefcountMapPtr()
pthread_mutex_t * lock_cache_refcount_
FdRefcountMgr * Clone()
static uint32_t hasher_int(const int &key)
unsigned char digest[digest_size_]
Definition: hash.h:124
int Open(const shash::Any id, const std::string &path)
static uint32_t hasher_any(const shash::Any &key)
SmallHashDynamic< int, FdRefcountInfo > map_refcount_
SmallHashDynamic< shash::Any, int > map_fd_
int Close(int fd)
SmallHashDynamic< shash::Any, int > * GetFdMapPtr()
FdRefcountInfo()
hash of the object opened through the fd
void AssignFrom(FdRefcountMgr *other)
uint32_t MurmurHash2(const void *key, int len, uint32_t seed)
Definition: murmur.hxx:23
shash::Any id
refcount for the times the fd was opened in the cache