Tervel  1.0.0
A collection of wait-free containers and algorithms.
hp_list.h
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 Copyright (c) 2015 University of Central Florida's Computer Software Engineering
5 Scalable & Secure Systems (CSE - S3) Lab
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 */
25 #ifndef TERVEL_UTIL_MEMORY_HP_LIST_H_
26 #define TERVEL_UTIL_MEMORY_HP_LIST_H_
27 
28 #include <atomic>
29 #include <utility>
30 
31 #include <assert.h>
32 #include <stdint.h>
33 
34 #include <tervel/util/info.h>
35 #include <tervel/util/system.h>
36 #include <tervel/util/descriptor.h>
37 
38 
39 namespace tervel {
40 namespace util {
41 namespace memory {
42 namespace hp {
43 
44 class Element;
45 class ListManager;
46 
56 class ElementList {
57  public:
58  friend Element;
59  explicit ElementList(ListManager *manager) : manager_(manager) {}
60 
62 
63 
64  private:
65  // -------------------------
66  // FOR DEALING WITH MANAGERS
67  // -------------------------
68 
72  void send_to_manager();
73 
74 
75  // --------------------------------
76  // DEALS WITH UNSAFE LIST
77  // --------------------------------
82  void add_to_unsafe(Element* elem);
83 
88  void try_to_free_elements(bool dont_check = false);
89 
90 
91  // -------
92  // MEMBERS
93  // -------
94 
99 
104  Element *element_list_ {nullptr};
105 };
106 
107 } // namespace hp
108 } // namespace memory
109 } // namespace util
110 } // namespace tervel
111 
112 #endif // TERVEL_UTIL_MEMORY_HP_LIST_H_
void add_to_unsafe(Element *elem)
This function adds an Element to the unsafe list.
TODO(steven):
Definition: mcas.h:36
ListManager * manager_
This list's manager.
Definition: hp_list.h:98
void try_to_free_elements(bool dont_check=false)
Tries to free elements from the unsafe list.
Element * element_list_
A linked list of list elements.
Definition: hp_list.h:104
This class is used for the creation of Hazard Pointer Protected Objects Objects which extend it have ...
Definition: hp_element.h:53
friend Element
Definition: hp_list.h:58
Encapsulates a shared central 'to free list' between several thread-local lists.
Definition: list_manager.h:58
ElementList(ListManager *manager)
Definition: hp_list.h:59
Defines a list of objects which are stored until they are safe to be freed.
Definition: hp_list.h:56
~ElementList()
Definition: hp_list.h:61
void send_to_manager()
Sends all elements managed by this list to the parent.