diff --git a/src/execution_profile.cpp b/src/execution_profile.cpp index e57e6b75e..6292be440 100644 --- a/src/execution_profile.cpp +++ b/src/execution_profile.cpp @@ -108,7 +108,6 @@ CassError cass_execution_profile_set_latency_aware_routing_settings( CassError cass_execution_profile_set_whitelist_filtering(CassExecProfile* profile, const char* hosts) { return cass_execution_profile_set_whitelist_filtering_n(profile, hosts, SAFE_STRLEN(hosts)); - return CASS_OK; } CassError cass_execution_profile_set_whitelist_filtering_n(CassExecProfile* profile, diff --git a/src/mpmc_queue.hpp b/src/mpmc_queue.hpp index f6cd146ca..e85975d83 100644 --- a/src/mpmc_queue.hpp +++ b/src/mpmc_queue.hpp @@ -56,9 +56,10 @@ class MPMCQueue : public Allocated { // buffer must be a size which is a power of 2. this also allows // the sequence to double as a ticket/lock. size_t pos = tail_.load(MEMORY_ORDER_RELAXED); + Node* node; for (;;) { - Node* node = &buffer_[pos & mask_]; + node = &buffer_[pos & mask_]; size_t node_seq = node->seq.load(MEMORY_ORDER_ACQUIRE); intptr_t dif = (intptr_t)node_seq - (intptr_t)pos; @@ -69,11 +70,7 @@ class MPMCQueue : public Allocated { // weak compare is faster, but can return spurious results // which in this instance is OK, because it's in the loop if (tail_.compare_exchange_weak(pos, pos + 1, MEMORY_ORDER_RELAXED)) { - // set the data - node->data = data; - // increment the sequence so that the tail knows it's accessible - node->seq.store(pos + 1, MEMORY_ORDER_RELEASE); - return true; + break; } } else if (dif < 0) { // if seq is less than head seq then it means this slot is @@ -85,15 +82,19 @@ class MPMCQueue : public Allocated { } } - // never taken - return false; + // set the data + node->data = data; + // increment the sequence so that the tail knows it's accessible + node->seq.store(pos + 1, MEMORY_ORDER_RELEASE); + return true; } bool dequeue(T& data) { size_t pos = head_.load(MEMORY_ORDER_RELAXED); + Node* node; for (;;) { - Node* node = &buffer_[pos & mask_]; + node = &buffer_[pos & mask_]; size_t node_seq = node->seq.load(MEMORY_ORDER_ACQUIRE); intptr_t dif = (intptr_t)node_seq - (intptr_t)(pos + 1); @@ -104,12 +105,7 @@ class MPMCQueue : public Allocated { // weak compare is faster, but can return spurious results // which in this instance is OK, because it's in the loop if (head_.compare_exchange_weak(pos, pos + 1, MEMORY_ORDER_RELAXED)) { - // set the output - data = node->data; - // set the sequence to what the head sequence should be next - // time around - node->seq.store(pos + mask_ + 1, MEMORY_ORDER_RELEASE); - return true; + break; } } else if (dif < 0) { // if seq is less than head seq then it means this slot is @@ -121,8 +117,12 @@ class MPMCQueue : public Allocated { } } - // never taken - return false; + // set the output + data = node->data; + // set the sequence to what the head sequence should be next + // time around + node->seq.store(pos + mask_ + 1, MEMORY_ORDER_RELEASE); + return true; } bool is_empty() const {