Commit a60c8646 authored by Xin Liu's avatar Xin Liu Committed by Jordan DeLong

fixing rwspinlock test Summary:

Summary:
gcc seems to treat this as declaration:

RWSpinLock::UpgradedHolder ug(
RWSpinLock::WriteHolder(
RWSpinLock::ReadHolder(&lock)));

Test Plan: add LOG(INFO) to make sure the holder converstions did get executed.

Reviewed By: marcelo.juchem@fb.com

FB internal diff: D688748
parent 378a3bbc
/* /*
* Copyright 2012 Facebook, Inc. * Copyright 2013 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -200,11 +200,10 @@ TEST(RWSpinLock, concurrent_holder_test) { ...@@ -200,11 +200,10 @@ TEST(RWSpinLock, concurrent_holder_test) {
while (!stop.load(std::memory_order_acquire)) { while (!stop.load(std::memory_order_acquire)) {
auto r = (uint32_t)(rand()) % 10; auto r = (uint32_t)(rand()) % 10;
if (r < 3) { // starts from write lock if (r < 3) { // starts from write lock
RWSpinLock::ReadHolder rg( RWSpinLock::ReadHolder rg{
RWSpinLock::UpgradedHolder ug( RWSpinLock::UpgradedHolder{
RWSpinLock::WriteHolder(&lock))); RWSpinLock::WriteHolder{&lock}}};
writes.fetch_add(1, std::memory_order_acq_rel);; writes.fetch_add(1, std::memory_order_acq_rel);;
} else if (r < 6) { // starts from upgrade lock } else if (r < 6) { // starts from upgrade lock
RWSpinLock::UpgradedHolder ug(&lock); RWSpinLock::UpgradedHolder ug(&lock);
if (r < 4) { if (r < 4) {
...@@ -214,9 +213,7 @@ TEST(RWSpinLock, concurrent_holder_test) { ...@@ -214,9 +213,7 @@ TEST(RWSpinLock, concurrent_holder_test) {
} }
upgrades.fetch_add(1, std::memory_order_acq_rel);; upgrades.fetch_add(1, std::memory_order_acq_rel);;
} else { } else {
RWSpinLock::UpgradedHolder ug( RWSpinLock::ReadHolder rg{&lock};
RWSpinLock::WriteHolder(
RWSpinLock::ReadHolder(&lock)));
reads.fetch_add(1, std::memory_order_acq_rel); reads.fetch_add(1, std::memory_order_acq_rel);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment