Skip to content

Commit 550a9aa

Browse files
authored
Merge pull request #272 from cf-natali/charles-is-lock-free-constexpr
Make is_lock_free constexpr.
2 parents feb72d0 + 14838d1 commit 550a9aa

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

blockingconcurrentqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class BlockingConcurrentQueue
544544
// Returns true if the underlying atomic variables used by
545545
// the queue are lock-free (they should be on most platforms).
546546
// Thread-safe.
547-
static bool is_lock_free()
547+
static constexpr bool is_lock_free()
548548
{
549549
return ConcurrentQueue::is_lock_free();
550550
}

concurrentqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ class ConcurrentQueue
13141314
// Returns true if the underlying atomic variables used by
13151315
// the queue are lock-free (they should be on most platforms).
13161316
// Thread-safe.
1317-
static bool is_lock_free()
1317+
static constexpr bool is_lock_free()
13181318
{
13191319
return
13201320
details::static_is_lock_free<bool>::value == 2 &&

tests/unittests/unittests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,9 +3643,9 @@ class ConcurrentQueueTests : public TestClass<ConcurrentQueueTests>
36433643

36443644
// is_lock_free()
36453645
{
3646-
bool lockFree = ConcurrentQueue<Foo, Traits>::is_lock_free();
3646+
constexpr bool lockFree = ConcurrentQueue<Foo, Traits>::is_lock_free();
36473647
#if defined(__amd64__) || defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__) || defined(_M_PPC) || defined(__powerpc__)
3648-
ASSERT_OR_FAIL(lockFree);
3648+
static_assert(lockFree, "is_lock_free should be true");
36493649
#else
36503650
(void)lockFree;
36513651
#endif

0 commit comments

Comments
 (0)