CUBRID Engine  latest
lockfree_transaction_reclaimable.hpp
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 
19 //
20 // lock-free transaction reclaimable nodes
21 //
22 // Lock-free data structures needs to be tagged with a reclaimable node (by either derivation or composition).
23 // When node is to be removed from structure, it is retired, collected by thread's transaction descriptor and
24 // safely reclaimed later.
25 //
26 // See lockfree_transaction_system.hpp description for an overview of the lock-free transaction implementation.
27 //
28 
29 #ifndef _LOCKFREE_TRANSACTION_RECLAIMABLE_HPP_
30 #define _LOCKFREE_TRANSACTION_RECLAIMABLE_HPP_
31 
33 
34 namespace lockfree
35 {
36  namespace tran
37  {
38  class descriptor;
39  } // namespace tran
40 } // namespace lockfree
41 
42 namespace lockfree
43 {
44  namespace tran
45  {
47  {
48  public:
50  : m_retired_next (NULL)
51  , m_retire_tranid (0)
52  {
53  }
54  virtual ~reclaimable_node () = default;
55 
56  // override reclaim to change what happens with the reclaimable node
57  virtual void reclaim ()
58  {
59  // default is to delete itself
60  delete this;
61  }
62 
63  protected:
64  reclaimable_node *m_retired_next; // link to next retired node
65  // may be repurposed by derived classes
66 
67  private:
68  friend descriptor; // descriptor can access next and transaction id
69 
71  };
72  } // namespace tran
73 } // namespace lockfree
74 
75 #endif // !_LOCKFREE_TRANSACTION_RECLAIMABLE_HPP_
#define NULL
Definition: freelistheap.h:34