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