Update concurrentqueue to 1.0.2

1.0.2 resolves compiler warnings for MSVC 2019 with C++17 support (https://github.com/cameron314/concurrentqueue/commit/9cfda6cc61065d016ae3f51f486ce0fae563ea87)
This commit is contained in:
Kyle Schwarz
2020-08-10 10:20:00 -04:00
parent 154eab4b1b
commit 7b3782cbe7
6 changed files with 141 additions and 85 deletions
@@ -277,7 +277,7 @@ struct ThreadLocal
auto raw = static_cast<char*>(corealgos_allocator::malloc(sizeof(InnerHash) + std::alignment_of<KeyValuePair>::value - 1 + sizeof(KeyValuePair) * newCapacity));
if (raw == nullptr) {
// Allocation failed
currentHashCount.fetch_add(-1, std::memory_order_relaxed);
currentHashCount.fetch_add((uint32_t)-1, std::memory_order_relaxed);
resizeInProgress.clear(std::memory_order_relaxed);
return nullptr;
}
@@ -434,7 +434,7 @@ struct FreeList
assert((head->freeListRefs.load(std::memory_order_relaxed) & SHOULD_BE_ON_FREELIST) == 0);
// Decrease refcount twice, once for our ref, and once for the list's ref
head->freeListRefs.fetch_add(-2, std::memory_order_release);
head->freeListRefs.fetch_add(-2u, std::memory_order_release);
return head;
}
@@ -442,7 +442,7 @@ struct FreeList
// increased.
// Note that we don't need to release any memory effects, but we do need to ensure that the reference
// count decrement happens-after the CAS on the head.
refs = prevHead->freeListRefs.fetch_add(-1, std::memory_order_acq_rel);
refs = prevHead->freeListRefs.fetch_add(-1u, std::memory_order_acq_rel);
if (refs == SHOULD_BE_ON_FREELIST + 1) {
add_knowing_refcount_is_zero(prevHead);
}
@@ -484,7 +484,7 @@ bool run_test(uint64_t seed, int iterations, test_type& out_type, const char*& o
count = q.try_dequeue_bulk(bulkData.begin(), bulkData.size());
}
for (std::size_t k = 0; k != count; ++k) {
auto item = bulkData[k];
item = bulkData[k];
ASSERT_OR_FAIL_THREAD((item & 0xFFFFFF) >= 0 && (item & 0xFFFFFF) < (int)largestOpCount);
ASSERT_OR_FAIL_THREAD((item & 0xFFFFFF) > lastItems[item >> 24]);
lastItems[item >> 24] = item & 0xFFFFFF;
@@ -784,12 +784,12 @@ int main(int argc, char** argv)
}
}
int result = 0;
int exitCode = 0;
test_type test;
const char* failReason;
if (singleSeed) {
if (!run_test(seed, SINGLE_SEED_ITERATIONS, test, failReason)) {
result = 1;
exitCode = 1;
std::ofstream fout(LOG_FILE, std::ios::app);
fout << test_names[test] << " failed: " << failReason << std::endl;
std::printf(" %s failed: %s\n", test_names[test], failReason);
@@ -818,7 +818,7 @@ int main(int argc, char** argv)
std::signal(SIGSEGV, signal_handler);
std::signal(SIGABRT, signal_handler);
int result;
bool result;
try {
result = run_test(seed, 2, test, failReason);
}
@@ -839,7 +839,7 @@ int main(int argc, char** argv)
std::signal(SIGABRT, SIG_DFL);
if (!result) {
result = 1;
exitCode = 1;
std::ofstream fout(LOG_FILE, std::ios::app);
fout << "*** Failure detected!\n Seed: " << std::hex << seed << "\n Test: " << test_names[test] << "\n Reason: " << failReason << std::endl;
std::printf("*** Failure detected!\n Seed: %08x%08x\n Test: %s\n Reason: %s\n", (uint32_t)(seed >> 32), (uint32_t)(seed), test_names[test], failReason);
@@ -863,5 +863,5 @@ int main(int argc, char** argv)
}
}
return result;
return exitCode;
}
@@ -274,6 +274,11 @@ public:
#define SUPER_ALIGNMENT 128
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4324) // structure was padded due to alignment specifier
#endif
struct MOODYCAMEL_ALIGNAS(SUPER_ALIGNMENT) VeryAligned {
static size_t errors;
@@ -305,6 +310,11 @@ struct MOODYCAMEL_ALIGNAS(SUPER_ALIGNMENT) VeryAligned {
};
size_t VeryAligned::errors = 0;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
class ConcurrentQueueTests : public TestClass<ConcurrentQueueTests>
{
@@ -403,35 +413,35 @@ public:
ASSERT_OR_FAIL(!details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = 0; b = 1 << 31;
a = 0; b = 1u << 31;
ASSERT_OR_FAIL(!details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = 1; b = 1 << 31;
a = 1; b = 1u << 31;
ASSERT_OR_FAIL(details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = 0; b = (1 << 31) + 1;
a = 0; b = (1u << 31) + 1;
ASSERT_OR_FAIL(!details::circular_less_than(a, b));
ASSERT_OR_FAIL(details::circular_less_than(b, a));
a = 100; b = (1 << 31) + 1;
a = 100; b = (1u << 31) + 1;
ASSERT_OR_FAIL(details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = (1 << 31) + 7; b = 5;
a = (1u << 31) + 7; b = 5;
ASSERT_OR_FAIL(details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = (1 << 16) + 7; b = (1 << 16) + 5;
a = (1u << 16) + 7; b = (1 << 16) + 5;
ASSERT_OR_FAIL(!details::circular_less_than(a, b));
ASSERT_OR_FAIL(details::circular_less_than(b, a));
a = 0xFFFFFFFF; b = 0;
a = 0xFFFFFFFFu; b = 0;
ASSERT_OR_FAIL(details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
a = 0xFFFFFFFF; b = 0xFFFFFF;
a = 0xFFFFFFFFu; b = 0xFFFFFFu;
ASSERT_OR_FAIL(details::circular_less_than(a, b));
ASSERT_OR_FAIL(!details::circular_less_than(b, a));
}
@@ -2059,7 +2069,7 @@ public:
bool success[2] = { true, true };
for (int i = 0; i != 2; ++i) {
if (i == 0) {
threads[i] = SimpleThread([&](int i) {
threads[i] = SimpleThread([&](int) {
// Producer
ProducerToken tok(q);
for (int i = 0; i != 32*1024; ++i) {
@@ -2068,7 +2078,7 @@ public:
}, i);
}
else {
threads[i] = SimpleThread([&](int i) {
threads[i] = SimpleThread([&](int) {
// Consumer
int items[5];
int prevItem = -1;
@@ -2108,7 +2118,7 @@ public:
bool success[2] = { true, true };
for (int i = 0; i != 2; ++i) {
if (i == 0) {
threads[i] = SimpleThread([&](int i) {
threads[i] = SimpleThread([&](int) {
// Producer
for (int i = 0; i != 32*1024; ++i) {
q.enqueue(i);
@@ -2116,7 +2126,7 @@ public:
}, i);
}
else {
threads[i] = SimpleThread([&](int i) {
threads[i] = SimpleThread([&](int) {
// Consumer
int items[5];
int prevItem = -1;
@@ -4666,7 +4676,7 @@ public:
auto item = local.get_or_create();
item->value = (int)tid;
for (int i = 0; i != 1024; ++i) {
auto item = local.get_or_create();
item = local.get_or_create();
if (item->value != (int)tid) {
failed[tid] = true;
}
@@ -4840,8 +4850,8 @@ public:
else {
ASSERT_OR_FAIL(removed[i].load(std::memory_order_relaxed));
}
auto removed = hash.remove(i);
ASSERT_OR_FAIL(removed == val);
auto removedVal = hash.remove(i);
ASSERT_OR_FAIL(removedVal == val);
}
for (int i = 0; i != MAX_ENTRIES; ++i) {
ASSERT_OR_FAIL(hash.find(i) == nullptr);