From ad25389b017c7b42d9d3878341dad49056030422 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 16 May 2011 14:31:27 +0200 Subject: [PATCH] lockfree: use type traits to ensure trivial assignment Signed-off-by: Tim Blechmann --- boost/lockfree/fifo.hpp | 27 ++++++++++++--------------- boost/lockfree/stack.hpp | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/boost/lockfree/fifo.hpp b/boost/lockfree/fifo.hpp index 3d085bc..db1b6a9 100644 --- a/boost/lockfree/fifo.hpp +++ b/boost/lockfree/fifo.hpp @@ -15,25 +15,21 @@ #ifndef BOOST_LOCKFREE_FIFO_HPP_INCLUDED #define BOOST_LOCKFREE_FIFO_HPP_INCLUDED -#include -#include -#include - -#include -#include - #include /* std::auto_ptr */ + +#include #include #include -#include +#include +#include -namespace boost -{ -namespace lockfree -{ +#include +#include +#include -namespace detail -{ +namespace boost { +namespace lockfree { +namespace detail { template class fifo: @@ -244,6 +240,8 @@ template { + BOOST_STATIC_ASSERT(boost::has_trivial_assign::value); + public: //! Construct fifo. fifo(void) @@ -345,5 +343,4 @@ public: } /* namespace lockfree */ } /* namespace boost */ - #endif /* BOOST_LOCKFREE_FIFO_HPP_INCLUDED */ diff --git a/boost/lockfree/stack.hpp b/boost/lockfree/stack.hpp index 4fd7c6d..60f7de2 100644 --- a/boost/lockfree/stack.hpp +++ b/boost/lockfree/stack.hpp @@ -9,31 +9,30 @@ #ifndef BOOST_LOCKFREE_STACK_HPP_INCLUDED #define BOOST_LOCKFREE_STACK_HPP_INCLUDED -#include #include - +#include #include +#include #include -#include +#include #include -#include - +#include -namespace boost -{ -namespace lockfree -{ +namespace boost { +namespace lockfree { -/** It uses a freelist for memory management, freed nodes are pushed to the freelist and not returned to - * the os before the stack is destroyed. +/** The stack class provides a multi-writer/multi-reader stack, pushing and poping is lockfree, + * construction/destruction has to be synchronized. It uses a freelist for memory management, + * freed nodes are pushed to the freelist and not returned to the os before the stack is destroyed. * * The memory management of the stack can be controlled via its freelist_t template argument. Two different * freelists can be used. struct caching_freelist_t selects a caching freelist, which can allocate more nodes * from the operating system, and struct static_freelist_t uses a fixed-sized freelist. With a fixed-sized * freelist, the push operation may fail, while with a caching freelist, the push operation may block. * + * \b Limitation: The class T is required to have a trivial assignment operator. * */ template ::value); + #ifndef BOOST_DOXYGEN_INVOKED struct node { @@ -181,7 +182,6 @@ private: #endif }; - } /* namespace lockfree */ } /* namespace boost */ -- 2.11.4.GIT