Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
Loading...
Searching...
No Matches
_node_handle_impl.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019-2020 Intel Corporation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef __TBB_node_handle_H
18#define __TBB_node_handle_H
19
20#include "_allocator_traits.h"
21#include "../tbb_config.h"
22
23
24namespace tbb {
25
26// This classes must be declared here for correct friendly relationship
27// TODO: Consider creation some internal class to access node_handle private fields without any friendly classes
28namespace interface5 {
29namespace internal {
30 template <typename T, typename Allocator>
31 class split_ordered_list;
32 template <typename Traits>
33 class concurrent_unordered_base;
34}
35}
36
37namespace interface10{
38namespace internal {
39 template<typename Traits>
40 class concurrent_skip_list;
41}
42}
43
44namespace internal {
45
46template<typename Value, typename Node, typename Allocator>
48public:
49 typedef Allocator allocator_type;
50protected:
51 typedef Node node;
53public:
54
58 nh.my_node = NULL;
59 }
60
61 bool empty() const { return my_node == NULL; }
62 explicit operator bool() const { return my_node != NULL; }
63
65
68 my_node = nh.my_node;
70 tbb::internal::allocator_move_assignment(my_allocator, nh.my_allocator, pocma_type());
71 nh.deactivate();
72 return *this;
73 }
74
76 std::swap(my_node, nh.my_node);
77 typedef typename traits_type::propagate_on_container_swap pocs_type;
79 }
80
82 return my_allocator;
83 }
84
85protected:
87
89 if(my_node) {
92 node_allocator.deallocate(my_node, 1);
93 }
94 }
95
96 void deactivate() { my_node = NULL; }
97
100};
101
102// node handle for maps
103template<typename Key, typename Value, typename Node, typename Allocator>
104class node_handle : public node_handle_base<Value, Node, Allocator> {
106public:
107 typedef Key key_type;
108 typedef typename Value::second_type mapped_type;
110
112
113 key_type& key() const {
114 __TBB_ASSERT(!this->empty(), "Cannot get key from the empty node_type object");
115 return *const_cast<key_type*>(&(this->my_node->value().first));
116 }
117
118 mapped_type& mapped() const {
119 __TBB_ASSERT(!this->empty(), "Cannot get mapped value from the empty node_type object");
120 return this->my_node->value().second;
121 }
122
123private:
124 template<typename T, typename A>
126
127 template<typename Traits>
129
130 template<typename Traits>
132
134};
135
136// node handle for sets
137template<typename Key, typename Node, typename Allocator>
138class node_handle<Key, Key, Node, Allocator> : public node_handle_base<Key, Node, Allocator> {
140public:
141 typedef Key value_type;
143
145
146 value_type& value() const {
147 __TBB_ASSERT(!this->empty(), "Cannot get value from the empty node_type object");
148 return *const_cast<value_type*>(&(this->my_node->value()));
149 }
150
151private:
152 template<typename T, typename A>
154
155 template<typename Traits>
157
158 template<typename Traits>
160
162};
163
164
165}// namespace internal
166}// namespace tbb
167
168#endif /*__TBB_node_handle_H*/
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
STL namespace.
The graph class.
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
void allocator_swap(MyAlloc &my_allocator, OtherAlloc &other_allocator, traits_true_type)
void allocator_move_assignment(MyAlloc &my_allocator, OtherAlloc &other_allocator, traits_true_type)
static void destroy(allocator_type &, T *p)
allocator_traits< Alloc >::template rebind_alloc< T >::other type
void swap(node_handle_base &nh)
allocator_type get_allocator() const
node_handle_base(node_handle_base &&nh)
tbb::internal::allocator_traits< allocator_type > traits_type
node_handle_base & operator=(node_handle_base &&nh)
base_type::allocator_type allocator_type
mapped_type & mapped() const
Value::second_type mapped_type
node_handle(typename base_type::node *n)
node_handle_base< Value, Node, Allocator > base_type
node_handle_base< Key, Node, Allocator > base_type

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.