You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.1 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/synch/spin_policies.hpp
  3. *
  4. * Purpose: Policies for spin mutexes.
  5. *
  6. * Created: 25th November 2006
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2006-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file stlsoft/synch/spin_policies.hpp
  40. *
  41. * \brief [C++ only] Definition of stlsoft::spin_yield and
  42. * stlsoft::spin_no_yield policy classes
  43. * (\ref group__library__synch "Synchronisation" Library).
  44. */
  45. #ifndef STLSOFT_INCL_STLSOFT_SYNCH_HPP_SPIN_POLICIES
  46. #define STLSOFT_INCL_STLSOFT_SYNCH_HPP_SPIN_POLICIES
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define STLSOFT_VER_STLSOFT_SYNCH_HPP_SPIN_POLICIES_MAJOR 1
  49. # define STLSOFT_VER_STLSOFT_SYNCH_HPP_SPIN_POLICIES_MINOR 0
  50. # define STLSOFT_VER_STLSOFT_SYNCH_HPP_SPIN_POLICIES_REVISION 1
  51. # define STLSOFT_VER_STLSOFT_SYNCH_HPP_SPIN_POLICIES_EDIT 4
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  57. # include <stlsoft/stlsoft.h>
  58. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  59. #ifndef STLSOFT_INCL_STLSOFT_SYNCH_HPP_CONCEPTS
  60. # include <stlsoft/synch/concepts.hpp>
  61. #endif /* !STLSOFT_INCL_STLSOFT_SYNCH_HPP_CONCEPTS */
  62. /* /////////////////////////////////////////////////////////////////////////
  63. * Namespace
  64. */
  65. #ifndef _STLSOFT_NO_NAMESPACE
  66. namespace stlsoft
  67. {
  68. #endif /* _STLSOFT_NO_NAMESPACE */
  69. /* /////////////////////////////////////////////////////////////////////////
  70. * Classes
  71. */
  72. /** \brief This policy causes spin mutex types default behaviour to be to
  73. * yield the current time slice when the spin variable cannot be acquired.
  74. *
  75. * \ingroup group__library__synch
  76. */
  77. struct spin_yield
  78. {
  79. enum
  80. {
  81. value = true
  82. };
  83. };
  84. /** \brief This policy causes spin mutex types default behaviour to be to
  85. * <b>not</b> yield the current time slice when the spin variable cannot
  86. * be acquired.
  87. *
  88. * \ingroup group__library__synch
  89. */
  90. struct spin_no_yield
  91. {
  92. enum
  93. {
  94. value = false
  95. };
  96. };
  97. /* ////////////////////////////////////////////////////////////////////// */
  98. #ifndef _STLSOFT_NO_NAMESPACE
  99. } // namespace stlsoft
  100. #endif /* _STLSOFT_NO_NAMESPACE */
  101. /* ////////////////////////////////////////////////////////////////////// */
  102. #endif /* !STLSOFT_INCL_STLSOFT_SYNCH_HPP_SPIN_POLICIES */
  103. /* ///////////////////////////// end of file //////////////////////////// */