fixing rwspinlock test Summary:
authorXin Liu <xliu@fb.com>
Fri, 25 Jan 2013 18:21:44 +0000 (10:21 -0800)
committerJordan DeLong <jdelong@fb.com>
Mon, 4 Feb 2013 17:25:59 +0000 (09:25 -0800)
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

index 6b58c9a1f92a94b96bcc71f79f317772f04e71d7..745ad68f6cea17c9ae9005b9ced0892964f0e6ba 100644 (file)
@@ -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);
       }
     }