Skip to content

Commit f794a72

Browse files
committed
Provided move constructor & move assignment oper. for SpinLock to fix errors related to deleted copy ctors of atomics
Signed-Off-By: Salman A. Faruqi <[email protected]>
1 parent 09990a1 commit f794a72

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ set(CMAKE_BUILD_TYPE Debug)
4545

4646
#Set the compiler if the CXX environment variable is not set
4747
if (NOT CMAKE_CXX_COMPILER)
48-
set(CMAKE_CXX_COMPILER g++)
48+
set(CMAKE_CXX_COMPILER clang)
4949
endif()
5050
#Set the compiler if the CXX_STANDARD environment variable is not set
5151
if (NOT CMAKE_CXX_STANDARD)
@@ -58,7 +58,7 @@ endif()
5858
if (QUANTUM_VERBOSE_MAKEFILE)
5959
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
6060
endif()
61-
61+
set(CXX_EXTENSIONS ON)
6262
# Determine if this is a 32 or 64 bit build
6363
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
6464

quantum/impl/quantum_spinlock_impl.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ namespace quantum {
2828
//==============================================================================
2929
// SpinLock
3030
//==============================================================================
31+
inline
32+
SpinLock::SpinLock(SpinLock&& o) : _flag(o._flag.load()) { }
33+
34+
inline
35+
SpinLock& SpinLock::operator=(SpinLock&& o)
36+
{
37+
if(this != &o)
38+
{
39+
_flag.store(o._flag.load());
40+
}
41+
return *this;
42+
}
43+
3144
inline
3245
void SpinLock::lock()
3346
{

quantum/quantum_spinlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class SpinLock
3939
SpinLock(const SpinLock&) = delete;
4040

4141
/// @brief Move constructor.
42-
SpinLock(SpinLock&&) = default;
42+
SpinLock(SpinLock&&);
4343

4444
/// @brief Copy assignment operator.
4545
SpinLock& operator=(const SpinLock&) = delete;
4646

4747
/// @brief Move assignment operator.
48-
SpinLock& operator=(SpinLock&&) = default;
48+
SpinLock& operator=(SpinLock&&);
4949

5050
/// @brief Locks this object.
5151
/// @note Blocks the current thread until the lock is acquired. Blocking is achieved

0 commit comments

Comments
 (0)