CernVM-FS  2.13.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 *>(reinterpret_cast<const uint32_t *>(key.digest)
19  + 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<shash::Any, int> &map_fd);
43 
44  void AssignFrom(FdRefcountMgr *other);
45 
47 
49 
50  int Open(const shash::Any id, const std::string &path);
51 
52  int Close(int fd);
53 
54  int Dup(int fd);
55 
57 
58  private:
71  pthread_mutex_t *lock_cache_refcount_;
72 };
73 
74 #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:121
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