policies.hpp 1.7 KB

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