*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using folly::PackedSyncPtr;
namespace {
// Compile time check for packability. This requires that
// PackedSyncPtr is a POD struct on gcc.
using folly::PackedSyncPtr;
namespace {
// Compile time check for packability. This requires that
// PackedSyncPtr is a POD struct on gcc.
sp.setExtra(0x13);
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ((sp.get() + 1)->second, 7);
sp.setExtra(0x13);
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ((sp.get() + 1)->second, 7);
auto newP = new std::pair<int,int>();
sp.set(newP);
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ(sp.get(), newP);
sp.unlock();
auto newP = new std::pair<int,int>();
sp.set(newP);
EXPECT_EQ(sp.extra(), 0x13);
EXPECT_EQ(sp.get(), newP);
sp.unlock();
void push_back(const T& t) {
base.set((T*) realloc(base.get(),
(base.extra() + 1) * sizeof(T)));
void push_back(const T& t) {
base.set((T*) realloc(base.get(),
(base.extra() + 1) * sizeof(T)));
std::set<intptr_t> idsFound;
for (auto& elem : kv.second) {
EXPECT_TRUE(idsFound.insert(elem).second); // check for dups
std::set<intptr_t> idsFound;
for (auto& elem : kv.second) {
EXPECT_TRUE(idsFound.insert(elem).second); // check for dups