Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      atomic_is_lock_free

      From cppreference.com
      <c‎ |atomic
       
       
      Concurrency support library
       
      Defined in header<stdatomic.h>
      _Bool atomic_is_lock_free(constvolatile A* obj);
      (since C11)

      Determines if the atomic operations on all objects of the typeA (the type of the object pointed to byobj) are lock-free. In any given program execution, the result of callingatomic_is_lock_free is the same for all pointers of the same type.

      This is ageneric function defined for allatomic object typesA. The argument is pointer to a volatile atomic type to accept addresses of both non-volatile andvolatile (e.g. memory-mapped I/O) atomic objects, and volatile semantic is preserved when applying this operation to volatile atomic objects.

      It is unspecified whether the name of a generic function is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual function (e.g. parenthesized like(atomic_is_lock_free)(...)), or a program defines an external identifier with the name of a generic function, the behavior is undefined.

      Contents

      [edit]Parameters

      obj - pointer to the atomic object to inspect

      [edit]Return value

      true if the operations on all objects of the typeA are lock-free,false otherwise.

      [edit]Example

      Run this code
      #include <stdio.h>#include <stdatomic.h> _Atomicstruct A{int a[100];} a;_Atomicstruct B{int x, y;} b;int main(void){printf("_Atomic struct A is lock free? %s\n",             atomic_is_lock_free(&a)?"true":"false");printf("_Atomic struct B is lock free? %s\n",             atomic_is_lock_free(&b)?"true":"false");}

      Possible output:

      _Atomic struct A is lock free? false_Atomic struct B is lock free? true

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C standards.

      DRApplied toBehavior as publishedCorrect behavior
      DR 465C11this function was per-objectthis functions is per-type

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.17.5.1 The atomic_is_lock_free generic function (p: 205)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.17.5.1 The atomic_is_lock_free generic function (p: 280)

      [edit]See also

      indicates that the given atomic type is lock-free
      (macro constant)[edit]
      C++ documentation foratomic_is_lock_free
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/atomic/atomic_is_lock_free&oldid=138687"

      [8]ページ先頭

      ©2009-2026 Movatter.jp