Permalink
Browse files

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
  • Loading branch information...
1 parent 378a3bb commit a60c864687bcc6cc9da782c4cb277e3002207a53 Xin Liu committed with jdelong Jan 25, 2013
Showing with 5 additions and 8 deletions.
  1. +5 −8 folly/test/RWSpinLockTest.cpp
View
13 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);
}
}

0 comments on commit a60c864

Please sign in to comment.