From a60c864687bcc6cc9da782c4cb277e3002207a53 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Fri, 25 Jan 2013 10:21:44 -0800 Subject: [PATCH] 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 --- folly/test/RWSpinLockTest.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/folly/test/RWSpinLockTest.cpp b/folly/test/RWSpinLockTest.cpp index 6b58c9a1..745ad68f 100644 --- a/folly/test/RWSpinLockTest.cpp +++ b/folly/test/RWSpinLockTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,11 +200,10 @@ TEST(RWSpinLock, concurrent_holder_test) { while (!stop.load(std::memory_order_acquire)) { auto r = (uint32_t)(rand()) % 10; if (r < 3) { // starts from write lock - RWSpinLock::ReadHolder rg( - RWSpinLock::UpgradedHolder ug( - RWSpinLock::WriteHolder(&lock))); + RWSpinLock::ReadHolder rg{ + RWSpinLock::UpgradedHolder{ + RWSpinLock::WriteHolder{&lock}}}; writes.fetch_add(1, std::memory_order_acq_rel);; - } else if (r < 6) { // starts from upgrade lock RWSpinLock::UpgradedHolder ug(&lock); if (r < 4) { @@ -214,9 +213,7 @@ TEST(RWSpinLock, concurrent_holder_test) { } upgrades.fetch_add(1, std::memory_order_acq_rel);; } else { - RWSpinLock::UpgradedHolder ug( - RWSpinLock::WriteHolder( - RWSpinLock::ReadHolder(&lock))); + RWSpinLock::ReadHolder rg{&lock}; reads.fetch_add(1, std::memory_order_acq_rel); } } -- 2.34.1