CUBRID Engine  latest
lockfree_transaction_system.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <cassert>
22 
23 namespace lockfree
24 {
25  namespace tran
26  {
27  system::system (size_t max_tran_count)
28  : m_max_tran_per_table (max_tran_count)
29  , m_tran_idx_map ()
30  {
32  m_tran_idx_map.init (bitmap::chunking_style::ONE_CHUNK, static_cast<int> (max_tran_count),
34  }
35 
36  index
38  {
39  int ret = m_tran_idx_map.get_entry ();
40  if (ret < 0)
41  {
42  assert (false);
43  return INVALID_INDEX;
44  }
45  return static_cast<index> (ret);
46  }
47 
48  void
50  {
51  if (idx == INVALID_INDEX)
52  {
53  assert (false);
54  return;
55  }
56  m_tran_idx_map.free_entry (static_cast<int> (idx));
57  }
58 
59  size_t
61  {
62  return m_max_tran_per_table;
63  }
64  } // namespace tran
65 } // namespace lockfree
static const float FULL_USAGE_RATIO
static const index INVALID_INDEX
void free_entry(int entry_idx)
#define assert(x)
void init(chunking_style style, int entries_count, float usage_ratio)