Skip to content

Commit

Permalink
Merge pull request cameron314#272 from cf-natali/charles-is-lock-free…
Browse files Browse the repository at this point in the history
…-constexpr

Make is_lock_free constexpr.
  • Loading branch information
cameron314 authored Nov 28, 2021
2 parents feb72d0 + 14838d1 commit 550a9aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blockingconcurrentqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class BlockingConcurrentQueue
// Returns true if the underlying atomic variables used by
// the queue are lock-free (they should be on most platforms).
// Thread-safe.
static bool is_lock_free()
static constexpr bool is_lock_free()
{
return ConcurrentQueue::is_lock_free();
}
Expand Down
2 changes: 1 addition & 1 deletion concurrentqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ class ConcurrentQueue
// Returns true if the underlying atomic variables used by
// the queue are lock-free (they should be on most platforms).
// Thread-safe.
static bool is_lock_free()
static constexpr bool is_lock_free()
{
return
details::static_is_lock_free<bool>::value == 2 &&
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3643,9 +3643,9 @@ class ConcurrentQueueTests : public TestClass<ConcurrentQueueTests>

// is_lock_free()
{
bool lockFree = ConcurrentQueue<Foo, Traits>::is_lock_free();
constexpr bool lockFree = ConcurrentQueue<Foo, Traits>::is_lock_free();
#if defined(__amd64__) || defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__) || defined(_M_PPC) || defined(__powerpc__)
ASSERT_OR_FAIL(lockFree);
static_assert(lockFree, "is_lock_free should be true");
#else
(void)lockFree;
#endif
Expand Down

0 comments on commit 550a9aa

Please sign in to comment.