Chris@16
|
1 // boost lockfree
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright (C) 2011 Tim Blechmann
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
6 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_LOCKFREE_POLICIES_HPP_INCLUDED
|
Chris@16
|
10 #define BOOST_LOCKFREE_POLICIES_HPP_INCLUDED
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/parameter.hpp>
|
Chris@16
|
13 #include <boost/mpl/bool.hpp>
|
Chris@16
|
14 #include <boost/mpl/size_t.hpp>
|
Chris@16
|
15 #include <boost/mpl/void.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost {
|
Chris@16
|
18 namespace lockfree {
|
Chris@16
|
19
|
Chris@16
|
20 #ifndef BOOST_DOXYGEN_INVOKED
|
Chris@16
|
21 namespace tag { struct allocator ; }
|
Chris@16
|
22 namespace tag { struct fixed_sized; }
|
Chris@16
|
23 namespace tag { struct capacity; }
|
Chris@16
|
24
|
Chris@16
|
25 #endif
|
Chris@16
|
26
|
Chris@16
|
27 /** Configures a data structure as \b fixed-sized.
|
Chris@16
|
28 *
|
Chris@16
|
29 * The internal nodes are stored inside an array and they are addressed by array indexing. This limits the possible size of the
|
Chris@16
|
30 * queue to the number of elements that can be addressed by the index type (usually 2**16-2), but on platforms that lack
|
Chris@16
|
31 * double-width compare-and-exchange instructions, this is the best way to achieve lock-freedom.
|
Chris@16
|
32 * This implies that a data structure is bounded.
|
Chris@16
|
33 * */
|
Chris@16
|
34 template <bool IsFixedSized>
|
Chris@16
|
35 struct fixed_sized:
|
Chris@16
|
36 boost::parameter::template_keyword<tag::fixed_sized, boost::mpl::bool_<IsFixedSized> >
|
Chris@16
|
37 {};
|
Chris@16
|
38
|
Chris@16
|
39 /** Sets the \b capacity of a data structure at compile-time.
|
Chris@16
|
40 *
|
Chris@16
|
41 * This implies that a data structure is bounded and fixed-sized.
|
Chris@16
|
42 * */
|
Chris@16
|
43 template <size_t Size>
|
Chris@16
|
44 struct capacity:
|
Chris@16
|
45 boost::parameter::template_keyword<tag::capacity, boost::mpl::size_t<Size> >
|
Chris@16
|
46 {};
|
Chris@16
|
47
|
Chris@16
|
48 /** Defines the \b allocator type of a data structure.
|
Chris@16
|
49 * */
|
Chris@16
|
50 template <class Alloc>
|
Chris@16
|
51 struct allocator:
|
Chris@16
|
52 boost::parameter::template_keyword<tag::allocator, Alloc>
|
Chris@16
|
53 {};
|
Chris@16
|
54
|
Chris@16
|
55 }
|
Chris@16
|
56 }
|
Chris@16
|
57
|
Chris@16
|
58 #endif /* BOOST_LOCKFREE_POLICIES_HPP_INCLUDED */
|
Chris@16
|
59
|