CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
item_mem.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_INGESTION_ITEM_MEM_H_
6 #define CVMFS_INGESTION_ITEM_MEM_H_
7 
8 #include <pthread.h>
9 
10 #include <cassert>
11 #include <vector>
12 
13 #include "malloc_arena.h"
14 #include "util/atomic.h"
15 
21  public:
22  ItemAllocator();
24 
25  void *Malloc(unsigned size);
26  void Free(void *ptr);
27 
28  static int64_t total_allocated() { return atomic_read64(&total_allocated_); }
29 
30  private:
31  static const unsigned kArenaSize = 128 * 1024 * 1024; // 128 MB
33 
34  std::vector<MallocArena *> malloc_arenas_;
38  unsigned idx_last_arena_;
39  pthread_mutex_t lock_;
40 }; // class ItemAllocator
41 
42 #endif // CVMFS_INGESTION_ITEM_MEM_H_
int64_t atomic_int64
Definition: atomic.h:18
void * Malloc(unsigned size)
Definition: item_mem.cc:55
std::vector< MallocArena * > malloc_arenas_
Definition: item_mem.h:34
unsigned idx_last_arena_
Definition: item_mem.h:38
static atomic_int64 total_allocated_
Definition: item_mem.h:32
static const unsigned kArenaSize
Definition: item_mem.h:31
static void size_t size
Definition: smalloc.h:54
pthread_mutex_t lock_
Definition: item_mem.h:39
void Free(void *ptr)
Definition: item_mem.cc:16
static int64_t total_allocated()
Definition: item_mem.h:28