.. oe:namespace:: OEPlatform


.. meta::
   :keywords: OESpinlock, Spinlock


.. _OEPlatform_OESpinlock:

.. oe:class:: OESpinlock

   .. oe:api::

      struct OESpinlock

   The :ref:`OESpinlock <OEPlatform_OESpinlock>` class provides a portable
   mutual exclusion device, that is useful for protecting shared data
   structures from concurrent modification. It provides the exact same
   semantics as a :ref:`OEMutex <OEPlatform_OEMutex>` object, however, it has
   very different performance semantics. Spin locks will
   optimistically continually try to acquire the lock in a tight
   loop. :ref:`OEMutex <OEPlatform_OEMutex>` will typically yield the
   processor back to the operating system. Spin locks are useful to
   protect very cheap operations. 

   .. seealso::

      * :ref:`OELockSpinlock <OEPlatform_OELockSpinlock>` class

   .. oe:method:: Constructors

      .. oe:api::

         OESpinlock()

      Default constructor.

   .. oe:method:: Acquire

      .. oe:api::

         void Acquire()

      Acquires (locks) the :ref:`OESpinlock <OEPlatform_OESpinlock>`. If the
      :ref:`OESpinlock <OEPlatform_OESpinlock>` is unlocked, it is locked by
      this thread and becomes owned by the calling thread. If the
      :ref:`OESpinlock <OEPlatform_OESpinlock>` is already locked, by this or
      another thread, :oe:meth:`OEPlatform::OESpinlock::Acquire` spins
      in a tight loop until the :ref:`OESpinlock <OEPlatform_OESpinlock>` is
      released. No attempt is made at fairness between threads. 

   .. oe:method:: Release

      .. oe:api::

         void Release()

      Releases (unlocks) the :ref:`OESpinlock <OEPlatform_OESpinlock>`.

