/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
namespace cds { namespace intrusive {
/// Lock-free free list
- /** @ingroup cds_intrusive_helper
+ /** @ingroup cds_intrusive_freelist
- Free list is a helper class intended for reusing objects instead of freeing them completely;
+ Free list is a helper class intended for reusing objects instead of freeing them completely;
this avoids the overhead of \p malloc(), and also avoids its worst-case behavior of taking an operating system lock.
So, the free list can be considered as a specialized allocator for objects of some type.
The algorithm is taken from <a href="http://moodycamel.com/blog/2014/solving-the-aba-problem-for-lock-free-free-lists">this article</a>.
The algo does not require any SMR like Hazard Pointer to prevent ABA problem.
- There is \ref TaggedFreeList "tagged pointers" variant of free list for processors which support double-width CAS.
+ There is \ref TaggedFreeList "tagged pointers" variant of free list for processors with double-width CAS support.
\b How to use
\code
node()
: m_freeListRefs( 0 )
- , m_freeListNext( nullptr )
- {}
+ {
+ m_freeListNext.store( nullptr, atomics::memory_order_release );
+ }
//@endcond
};
*/
~FreeList()
{
- assert( empty() );
+ assert( empty());
}
/// Puts \p pNode to the free list