OpenSDN source code
ksync_index.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef ctrlplane_ksync_index_table_h
7 #define ctrlplane_ksync_index_table_h
8 
9 #include <boost/dynamic_bitset.hpp>
10 
12 public:
14 
15  KSyncIndexTable(unsigned int count) : table_(count) {
16  table_.set();
17  };
18 
20  //assert(table_.count() == table_.size());
21  table_.clear();
22  };
23 
24  size_t Alloc() {
25  size_t index = table_.find_first();
26  assert(index != table_.npos);
27  table_.set(index, 0);
28  return index;
29  };
30 
31  void Free(size_t index) {
32  assert(index < table_.size());
33  assert(table_[index] == 0);
34  table_.set(index);
35  };
36 
37 private:
38  typedef boost::dynamic_bitset<> Bitmap;
40 };
41 
42 #endif // ctrlplane_ksync_index_table_h
boost::dynamic_bitset Bitmap
Definition: ksync_index.h:35
KSyncIndexTable(unsigned int count)
Definition: ksync_index.h:15
void Free(size_t index)
Definition: ksync_index.h:31
size_t Alloc()
Definition: ksync_index.h:24