Loading...
Searching...
No Matches
scoped_spin_lock.h
Go to the documentation of this file.
#ifndef HALIDE_SCOPED_SPIN_LOCK_H
#define HALIDE_SCOPED_SPIN_LOCK_H
namespace Halide {
namespace Runtime {
namespace Internal {
// An RAII spin lock.
struct ScopedSpinLock {
// Note that __atomic_test_and_set() requires use of a char (or bool)
typedef char AtomicFlag;
volatile AtomicFlag *const flag;
ALWAYS_INLINE explicit ScopedSpinLock(volatile AtomicFlag *flag)
: flag(flag) {
while (__atomic_test_and_set(flag, __ATOMIC_ACQUIRE)) {
// nothing
}
}
ALWAYS_INLINE ~ScopedSpinLock() {
__atomic_clear(flag, __ATOMIC_RELEASE);
}
};
} // namespace Internal
} // namespace Runtime
} // namespace Halide
#endif
Halide::Runtime::Internal
Definition constants.h:13
Halide::Runtime
Definition constants.h:12
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
ALWAYS_INLINE
#define ALWAYS_INLINE
Definition runtime_internal.h:57
Halide::Runtime::Internal::ScopedSpinLock::~ScopedSpinLock
ALWAYS_INLINE ~ScopedSpinLock()
Definition scoped_spin_lock.h:22
Halide::Runtime::Internal::ScopedSpinLock::AtomicFlag
char AtomicFlag
Definition scoped_spin_lock.h:11
Halide::Runtime::Internal::ScopedSpinLock::ScopedSpinLock
ALWAYS_INLINE ScopedSpinLock(volatile AtomicFlag *flag)
Definition scoped_spin_lock.h:15
Halide::Runtime::Internal::ScopedSpinLock::flag
volatile AtomicFlag *const flag
Definition scoped_spin_lock.h:13