atomic_flag

The atomic_flag type provides the classic test-and-set functionality.

atomic_flag

Description

The atomic_flag type provides the classic test-and-set functionality. It has two states, set (value is non-zero) and clear (value is 0). Operations on an object of type atomic_flag shall be lock free.

The macro ATOMIC_FLAG_INIT may be used to initialize an atomic_flag to the clear state. An atomic_flag that is not explicitly initialized with ATOMIC_FLAG_INIT is initially in an indeterminate state.

This macro can only be used for atomic objects that are declared in program scope in the global address space with the atomic_flag type.

Example

global atomic_flag guard = ATOMIC_FLAG_INIT;

Specification

OpenCL Specification

Also see

Atomic Functions

Copyright © 2007-2013 The Khronos Group Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.