Ada Programming/Libraries/System.Atomic Operations.Exchange

From Wikibooks, open books for an open world
Jump to navigation Jump to search

This language feature has been introduced in Ada 2022.

System.Atomic Operations.Exchange is a unit of the Predefined Language Environment since Ada 2022.

generic
   type Atomic_Type is private with Atomic;
package System.Atomic_Operations.Exchange
   with Pure, Nonblocking is

   function Atomic_Exchange (Item  : aliased in out Atomic_Type;
                             Value : Atomic_Type) return Atomic_Type
      with Convention => Intrinsic;

   function Atomic_Compare_And_Exchange 
     (Item    : aliased in out Atomic_Type;
      Prior   : aliased in out Atomic_Type;
      Desired : Atomic_Type) return Boolean
      with Convention => Intrinsic;

   function Is_Lock_Free (Item : aliased Atomic_Type) return Boolean
      with Convention => Intrinsic;

end System.Atomic_Operations.Exchange;