Subversion Repository Public Repository

Divide-Dependencies

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 9 vs 23 for /boost/boost/lockfree/detail/freelist.hpp

Diff revisions: vs.
  @@ -1,6 +1,6 @@
1 1 // lock-free freelist
2 2 //
3 - // Copyright (C) 2008, 2009, 2011 Tim Blechmann
3 + // Copyright (C) 2008-2013 Tim Blechmann
4 4 //
5 5 // Distributed under the Boost Software License, Version 1.0. (See
6 6 // accompanying file LICENSE_1_0.txt or copy at
  @@ -9,6 +9,7 @@
9 9 #ifndef BOOST_LOCKFREE_FREELIST_HPP_INCLUDED
10 10 #define BOOST_LOCKFREE_FREELIST_HPP_INCLUDED
11 11
12 + #include <limits>
12 13 #include <memory>
13 14
14 15 #include <boost/array.hpp>
  @@ -21,6 +22,12 @@
21 22 #include <boost/lockfree/detail/parameter.hpp>
22 23 #include <boost/lockfree/detail/tagged_ptr.hpp>
23 24
25 + #if defined(_MSC_VER)
26 + #pragma warning(push)
27 + #pragma warning(disable: 4100) // unreferenced formal parameter
28 + #pragma warning(disable: 4127) // conditional expression is constant
29 + #endif
30 +
24 31 namespace boost {
25 32 namespace lockfree {
26 33 namespace detail {
  @@ -109,7 +116,7 @@
109 116
110 117 ~freelist_stack(void)
111 118 {
112 - tagged_node_ptr current (pool_);
119 + tagged_node_ptr current = pool_.load();
113 120
114 121 while (current) {
115 122 freelist_node * current_ptr = current.get_ptr();
  @@ -174,7 +181,7 @@
174 181 }
175 182
176 183 freelist_node * new_pool_ptr = old_pool->next.get_ptr();
177 - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_tag() + 1);
184 + tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_next_tag());
178 185
179 186 if (pool_.compare_exchange_weak(old_pool, new_pool)) {
180 187 void * ptr = old_pool.get_ptr();
  @@ -196,7 +203,7 @@
196 203 }
197 204
198 205 freelist_node * new_pool_ptr = old_pool->next.get_ptr();
199 - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_tag() + 1);
206 + tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_next_tag());
200 207
201 208 pool_.store(new_pool, memory_order_relaxed);
202 209 void * ptr = old_pool.get_ptr();
  @@ -287,6 +294,12 @@
287 294 return tag;
288 295 }
289 296
297 + tag_t get_next_tag() const
298 + {
299 + tag_t next = (get_tag() + 1) & (std::numeric_limits<tag_t>::max)();
300 + return next;
301 + }
302 +
290 303 void set_tag(tag_t t)
291 304 {
292 305 tag = t;
  @@ -298,6 +311,11 @@
298 311 return (index == rhs.index) && (tag == rhs.tag);
299 312 }
300 313
314 + bool operator!=(tagged_index const & rhs) const
315 + {
316 + return !operator==(rhs);
317 + }
318 +
301 319 protected:
302 320 index_t index;
303 321 tag_t tag;
  @@ -314,7 +332,7 @@
314 332
315 333 // unused ... only for API purposes
316 334 template <typename Allocator>
317 - compiletime_sized_freelist_storage(Allocator const & alloc, std::size_t count)
335 + compiletime_sized_freelist_storage(Allocator const & /* alloc */, std::size_t /* count */)
318 336 {}
319 337
320 338 T * nodes(void) const
  @@ -523,7 +541,7 @@
523 541 T * old_node = NodeStorage::nodes() + index;
524 542 tagged_index * next_index = reinterpret_cast<tagged_index*>(old_node);
525 543
526 - tagged_index new_pool(next_index->get_index(), old_pool.get_tag() + 1);
544 + tagged_index new_pool(next_index->get_index(), old_pool.get_next_tag());
527 545
528 546 if (pool_.compare_exchange_weak(old_pool, new_pool))
529 547 return old_pool.get_index();
  @@ -541,7 +559,7 @@
541 559 T * old_node = NodeStorage::nodes() + index;
542 560 tagged_index * next_index = reinterpret_cast<tagged_index*>(old_node);
543 561
544 - tagged_index new_pool(next_index->get_index(), old_pool.get_tag() + 1);
562 + tagged_index new_pool(next_index->get_index(), old_pool.get_next_tag());
545 563
546 564 pool_.store(new_pool, memory_order_relaxed);
547 565 return old_pool.get_index();
  @@ -622,4 +640,9 @@
622 640 } /* namespace lockfree */
623 641 } /* namespace boost */
624 642
643 + #if defined(_MSC_VER)
644 + #pragma warning(pop)
645 + #endif
646 +
647 +
625 648 #endif /* BOOST_LOCKFREE_FREELIST_HPP_INCLUDED */