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.

160 lines
5.7 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: platformstl/synch/spin_mutex.hpp
  3. *
  4. * Purpose: Definition of the spin_mutex type.
  5. *
  6. * Created: 20th March 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2005-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 platformstl/synch/spin_mutex.hpp
  40. *
  41. * \brief [C++ only] Definition of the platformstl::spin_mutex type
  42. * (\ref group__library__synch "Synchronisation" Library).
  43. */
  44. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX
  45. #define PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX_MAJOR 2
  48. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX_MINOR 1
  49. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX_REVISION 1
  50. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX_EDIT 19
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Auto-generation and compatibility
  54. */
  55. /*
  56. [<[STLSOFT-AUTO:NO-UNITTEST]>]
  57. [Incompatibilies-start]
  58. [Incompatibilies-end]
  59. */
  60. /* /////////////////////////////////////////////////////////////////////////
  61. * Includes
  62. */
  63. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_HPP_PLATFORMSTL
  64. # include <platformstl/platformstl.hpp>
  65. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_HPP_PLATFORMSTL */
  66. #if defined(PLATFORMSTL_OS_IS_UNIX)
  67. # ifndef UNIXSTL_INCL_UNIXSTL_SYNCH_HPP_SPIN_MUTEX
  68. # include <unixstl/synch/spin_mutex.hpp>
  69. # endif /* !UNIXSTL_INCL_UNIXSTL_SYNCH_HPP_SPIN_MUTEX */
  70. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  71. # ifndef WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX
  72. # include <winstl/synch/spin_mutex.hpp>
  73. # endif /* !WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX */
  74. #else /* ? operating system */
  75. # error Operating system not discriminated
  76. #endif /* operating system */
  77. /* /////////////////////////////////////////////////////////////////////////
  78. * Namespace
  79. */
  80. #if defined(_STLSOFT_NO_NAMESPACE) || \
  81. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  82. /* There is no stlsoft namespace, so must define ::platformstl */
  83. namespace platformstl
  84. {
  85. #else
  86. /* Define stlsoft::platformstl_project */
  87. namespace stlsoft
  88. {
  89. namespace platformstl_project
  90. {
  91. #endif /* _STLSOFT_NO_NAMESPACE */
  92. /* ////////////////////////////////////////////////////////////////////// */
  93. #if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  94. /** \brief A spin mutex class
  95. *
  96. * The class is not actually defined in the
  97. * \link ::platformstl platformstl\endlink namespace. Rather, it
  98. * resolves to the appropriate type for the given platform, relying on
  99. * \ref section__principle__conformance__intersecting_conformance "Intersecting Conformance"
  100. * of the resolved platform-specific types.
  101. *
  102. * When compiling on UNIX platforms, the platformstl::spin_mutex
  103. * type resolves to the unixstl::spin_mutex class. On Windows platforms
  104. * it resolves to the winstl::spin_mutex class. It is not defined
  105. * for other platforms.
  106. */
  107. class spin_mutex
  108. {};
  109. #elif defined(PLATFORMSTL_OS_IS_UNIX)
  110. # ifdef _UNIXSTL_NO_NAMESPACE
  111. using ::spin_mutex;
  112. # else /* ? _UNIXSTL_NO_NAMESPACE */
  113. using ::unixstl::spin_mutex;
  114. # endif /* _UNIXSTL_NO_NAMESPACE */
  115. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  116. # ifdef _WINSTL_NO_NAMESPACE
  117. using ::spin_mutex;
  118. # else /* ? _WINSTL_NO_NAMESPACE */
  119. using ::winstl::spin_mutex;
  120. # endif /* _WINSTL_NO_NAMESPACE */
  121. #else /* ? operating system */
  122. # error Operating system not discriminated
  123. #endif /* operating system */
  124. /* ////////////////////////////////////////////////////////////////////// */
  125. #if defined(_STLSOFT_NO_NAMESPACE) || \
  126. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  127. } // namespace platformstl
  128. #else
  129. } // namespace platformstl_project
  130. } // namespace stlsoft
  131. #endif /* _STLSOFT_NO_NAMESPACE */
  132. /* ////////////////////////////////////////////////////////////////////// */
  133. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SPIN_MUTEX */
  134. /* ///////////////////////////// end of file //////////////////////////// */