#define SYNCHRONIZED(...) \
FOLLY_PUSH_WARNING \
FOLLY_GCC_DISABLE_WARNING(shadow) \
+ FOLLY_MSVC_DISABLE_WARNING(4189) /* initialized but unreferenced */ \
+ FOLLY_MSVC_DISABLE_WARNING(4456) /* declaration hides local */ \
+ FOLLY_MSVC_DISABLE_WARNING(4457) /* declaration hides parameter */ \
+ FOLLY_MSVC_DISABLE_WARNING(4458) /* declaration hides member */ \
+ FOLLY_MSVC_DISABLE_WARNING(4459) /* declaration hides global */ \
FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS \
if (bool SYNCHRONIZED_state = false) { \
} else \
auto barrier = std::make_shared<boost::barrier>(2);
Future<Unit> f;
{
- auto dag = FutureDAG::create();
- auto h1 = dag->add([barrier] {
+ auto localDag = FutureDAG::create();
+ auto h1 = localDag->add([barrier] {
auto p = std::make_shared<Promise<Unit>>();
std::thread t([p, barrier] {
barrier->wait();
t.detach();
return p->getFuture();
});
- auto h2 = dag->add(makeFutureFunc);
- dag->dependency(h1, h2);
- f = dag->go();
+ auto h2 = localDag->add(makeFutureFunc);
+ localDag->dependency(h1, h2);
+ f = localDag->go();
}
barrier->wait();
ASSERT_NO_THROW(f.get());
EXPECT_EQ(set.size(), 1);
- for (auto it : set) {
- EXPECT_EQ(it, "lo");
+ for (auto entry : set) {
+ EXPECT_EQ(entry, "lo");
}
}
EXPECT_EQ(set.size(), 1);
- for (auto it : set) {
- EXPECT_EQ(it, "lo");
+ for (auto entry : set) {
+ EXPECT_EQ(entry, "lo");
}
}
EXPECT_EQ(set2.size(), 2);
set2.erase("lo");
- for (auto it : set2) {
- EXPECT_EQ(it, "hello");
+ for (auto entry : set2) {
+ EXPECT_EQ(entry, "hello");
}
set2.clear();
EXPECT_EQ(map.size(), 1);
- for (auto& it : map) {
- EXPECT_EQ(it.first, "lo");
+ for (auto& entry : map) {
+ EXPECT_EQ(entry.first, "lo");
}
}
EXPECT_EQ(map2.size(), 2);
map2.erase("lo");
- for (auto& it : map2) {
- EXPECT_EQ(it.first, "hello");
+ for (auto& entry : map2) {
+ EXPECT_EQ(entry.first, "hello");
}
map2.clear();
}
void writeErr(
- size_t bytesWritten,
+ size_t nBytesWritten,
const AsyncSocketException& ex) noexcept override {
- std::cerr << "writeError: bytesWritten " << bytesWritten
+ std::cerr << "writeError: bytesWritten " << nBytesWritten
<< ", exception " << ex.what() << std::endl;
state = STATE_FAILED;
- this->bytesWritten = bytesWritten;
+ this->bytesWritten = nBytesWritten;
exception = ex;
socket_->close();
socket_->detachEventBase();
buffer = nullptr;
length = 0;
}
- void allocate(size_t length) {
+ void allocate(size_t len) {
assert(buffer == nullptr);
- this->buffer = static_cast<char*>(malloc(length));
- this->length = length;
+ this->buffer = static_cast<char*>(malloc(len));
+ this->length = len;
}
void free() {
::free(buffer);
}
}
- void writeErr(size_t bytesWritten,
+ void writeErr(size_t nBytesWritten,
const folly::AsyncSocketException& ex) noexcept override {
LOG(ERROR) << ex.what();
state = STATE_FAILED;
- this->bytesWritten = bytesWritten;
+ this->bytesWritten = nBytesWritten;
exception = ex;
if (errorCallback) {
errorCallback();
buffer = nullptr;
length = 0;
}
- void allocate(size_t length) {
+ void allocate(size_t len) {
assert(buffer == nullptr);
- this->buffer = static_cast<char*>(malloc(length));
- this->length = length;
+ this->buffer = static_cast<char*>(malloc(len));
+ this->length = len;
}
void free() {
::free(buffer);
template <class INT>
void testFLS() {
- typedef typename std::make_unsigned<INT>::type UINT;
+ typedef typename std::make_unsigned<INT>::type UINT_T;
EXPECT_EQ(0, findLastSet(static_cast<INT>(0)));
- size_t bits = std::numeric_limits<UINT>::digits;
+ size_t bits = std::numeric_limits<UINT_T>::digits;
for (size_t i = 0; i < bits; i++) {
- INT v1 = static_cast<UINT>(1) << i;
+ INT v1 = static_cast<UINT_T>(1) << i;
EXPECT_EQ(i + 1, findLastSet(v1));
- INT v2 = (static_cast<UINT>(1) << i) - 1;
+ INT v2 = (static_cast<UINT_T>(1) << i) - 1;
EXPECT_EQ(i, findLastSet(v2));
}
}
skipList.add(3);
CHECK(skipList.contains(3));
int pos = 0;
- FOR_EACH(it, skipList) {
- LOG(INFO) << "pos= " << pos++ << " value= " << *it;
+ for (auto entry : skipList) {
+ LOG(INFO) << "pos= " << pos++ << " value= " << entry;
}
}
template <typename ParentAlloc>
void NonTrivialDeallocationWithParanoid() {
using Alloc = ParanoidArenaAlloc<ParentAlloc>;
- using SkipListType =
+ using ParanoidSkipListType =
ConcurrentSkipList<NonTrivialValue, std::less<NonTrivialValue>, Alloc>;
ParentAlloc parentAlloc;
Alloc paranoidAlloc(&parentAlloc);
- auto list = SkipListType::createInstance(10, paranoidAlloc);
+ auto list = ParanoidSkipListType::createInstance(10, paranoidAlloc);
TestNonTrivialDeallocation(list);
EXPECT_TRUE(paranoidAlloc.isEmpty());
}
}
TEST(ConcurrentSkipList, NonTrivialDeallocationWithSysArena) {
- using SkipListType =
+ using SysArenaSkipListType =
ConcurrentSkipList<NonTrivialValue, std::less<NonTrivialValue>, SysArena>;
- auto list = SkipListType::createInstance(10);
+ auto list = SysArenaSkipListType::createInstance(10);
TestNonTrivialDeallocation(list);
}
auto i = to<int>(42.0);
EXPECT_EQ(i, 42);
try {
- auto i = to<int>(42.1);
- LOG(ERROR) << "to<int> returned " << i << " instead of throwing";
+ auto i2 = to<int>(42.1);
+ LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing";
EXPECT_TRUE(false);
} catch (std::range_error& e) {
//LOG(INFO) << e.what();
auto j = to<char>(x);
EXPECT_EQ(j, 42);
try {
- auto i = to<char>(y);
+ auto i2 = to<char>(y);
LOG(ERROR) << "to<char> returned "
- << static_cast<unsigned int>(i)
+ << static_cast<unsigned int>(i2)
<< " instead of throwing";
EXPECT_TRUE(false);
} catch (std::range_error& e) {
auto j = to<A>(100);
EXPECT_EQ(j, 100);
try {
- auto i = to<A>(5000000000L);
+ auto i2 = to<A>(5000000000L);
LOG(ERROR) << "to<A> returned "
- << static_cast<unsigned int>(i)
+ << static_cast<unsigned int>(i2)
<< " instead of throwing";
EXPECT_TRUE(false);
} catch (std::range_error& e) {
TEST(fbvector, clause_23_3_6_4_ambiguity) {
fbvector<int> v;
- fbvector<int>::const_iterator i = v.end();
- v.insert(i, 10, 20);
+ fbvector<int>::const_iterator it = v.end();
+ v.insert(it, 10, 20);
EXPECT_EQ(v.size(), 10);
- FOR_EACH (i, v) {
- EXPECT_EQ(*i, 20);
+ for (auto i : v) {
+ EXPECT_EQ(i, 20);
}
}
EXPECT_EQ("0042", sformat("{0[3]:04}", defaulted(v2, 42)));
EXPECT_EQ("0042", svformat("{3:04}", defaulted(v2, 42)));
- const int p[] = {10, 20, 30};
- const int* q = p;
- EXPECT_EQ("0020", sformat("{0[1]:04}", p));
- EXPECT_EQ("0020", svformat("{1:04}", p));
- EXPECT_EQ("0020", sformat("{0[1]:04}", q));
- EXPECT_EQ("0020", svformat("{1:04}", q));
- EXPECT_NE("", sformat("{}", q));
-
- EXPECT_EQ("0x", sformat("{}", p).substr(0, 2));
- EXPECT_EQ("10", svformat("{}", p));
- EXPECT_EQ("0x", sformat("{}", q).substr(0, 2));
- EXPECT_EQ("10", svformat("{}", q));
- q = nullptr;
- EXPECT_EQ("(null)", sformat("{}", q));
+ {
+ const int p[] = { 10, 20, 30 };
+ const int* q = p;
+ EXPECT_EQ("0020", sformat("{0[1]:04}", p));
+ EXPECT_EQ("0020", svformat("{1:04}", p));
+ EXPECT_EQ("0020", sformat("{0[1]:04}", q));
+ EXPECT_EQ("0020", svformat("{1:04}", q));
+ EXPECT_NE("", sformat("{}", q));
+
+ EXPECT_EQ("0x", sformat("{}", p).substr(0, 2));
+ EXPECT_EQ("10", svformat("{}", p));
+ EXPECT_EQ("0x", sformat("{}", q).substr(0, 2));
+ EXPECT_EQ("10", svformat("{}", q));
+ q = nullptr;
+ EXPECT_EQ("(null)", sformat("{}", q));
+ }
std::map<int, std::string> m { {10, "hello"}, {20, "world"} };
EXPECT_EQ("worldXX", sformat("{[20]:X<7}", m));