}
void unlock_shared() {
- QuarterInt val = __sync_fetch_and_add(&ticket.write, 1);
+ __sync_fetch_and_add(&ticket.write, 1);
}
class WriteHolder;
auto head = &buckets->buckets_[idx];
node = head->load(std::memory_order_relaxed);
Node* prev = nullptr;
- auto headnode = node;
while (node) {
if (KeyEqual()(key, node->getItem().first)) {
auto next = node->next_.load(std::memory_order_relaxed);
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
- unsigned long val;
auto res = m.insert(k, k).second;
if (res) {
res = m.erase(k);
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
- unsigned long val;
auto res = m.insert(k, k).second;
if (res) {
res = m.erase(k);
idleTimeout = MemoryIdler::getVariationTimeout(idleTimeout);
- scheduleTimeout(
+ scheduleTimeout(static_cast<uint32_t>(
std::chrono::duration_cast<std::chrono::milliseconds>(idleTimeout)
- .count());
+ .count()));
}
// reschedule this callback for the next event loop.
// complete length available
auto buf = folly::IOBuf::wrapBuffer(template_blob, 3);
auto len = folly::bser::decodePduLength(&*buf);
+ (void)len;
LOG(ERROR) << "managed to return a length, but only had 3 bytes";
}(),
std::out_of_range);
BENCHMARK(ExceptionTracer, iters) {
std::vector<std::thread> threads;
constexpr size_t kNumThreads = 10;
- threads.resize(10);
+ threads.resize(kNumThreads);
for (auto& t : threads) {
t = std::thread([iters]() { loop(iters); });
}
LogLevel level;
try {
level = stringToLogLevel(level_str);
- } catch (const std::exception& ex) {
+ } catch (const std::exception&) {
errors.emplace_back(folly::sformat(
"invalid log level \"{}\" for category \"{}\"", level_str, category));
continue;
TEST_F(FutureDAGTest, RemoveSingleNode) {
auto h1 = add();
auto h2 = add();
+ (void)h1;
remove(h2);
ASSERT_NO_THROW(dag->go().get());
checkOrder();
TestExecutor::~TestExecutor() {
for (auto& worker : workers_) {
+ (void)worker;
addImpl({});
}
| as<vector>();
auto square = [](int x) { return x * x; };
-auto add = [](int a, int b) { return a + b; };
-auto multiply = [](int a, int b) { return a * b; };
BENCHMARK(Sum_Basic_NoGen, iters) {
int limit = testSize.load();
constexpr int kFib = 28; // unit of work
size_t fib(int n) { return n <= 1 ? 1 : fib(n - 1) + fib(n - 2); }
-static auto add = [](int a, int b) { return a + b; };
-static auto mod7 = [](int i) { return i % 7; };
-
static auto isPrimeSlow = [](int n) {
if (n < 2) {
return false;
return factorsSlow(i) + sleepyWork(i);
};
-std::mutex block;
-static auto workAndBlock = [](int i) {
- int r = factorsSlow(i);
- {
- std::lock_guard<std::mutex> lock(block);
- return sleepyWork(i) + r;
- }
-};
-
auto start = 1 << 20;
auto v = seq(start) | take(1 << 20) | as<vector>();
auto small = from(v) | take(1 << 12);
{
auto input = "";
auto expected = vec{};
- EXPECT_EQ(expected, split("", ',') | collect);
+ EXPECT_EQ(expected, split(input, ',') | collect);
}
// The last delimiter is eaten, just like std::getline
FOR_EACH (i, v) {
EXPECT_EQ(*i, VECTOR::value_type());
}
- auto const n2 = random(0U, 10000U);
FOR_EACH (i, v) {
EXPECT_EQ(*i, VECTOR::value_type());
}
while (iters--) {
const char* val =
inet_ntop(AF_INET, &ip, outputString, sizeof(outputString));
+ folly::doNotOptimizeAway(val);
}
}
IPAddressV4 ip("127.0.0.1");
while (iters--) {
string outputString = ip.toFullyQualified();
+ folly::doNotOptimizeAway(outputString);
+ folly::doNotOptimizeAway(outputString.data());
}
}
IPAddressV6 ipv6Addr("F1E0:0ACE:FB94:7ADF:22E8:6DE6:9672:3725");
in6_addr ip = ipv6Addr.toAddr();
char outputString[INET6_ADDRSTRLEN] = {0};
- bool checkResult = (iters == 1);
while (iters--) {
const char* val =
inet_ntop(AF_INET6, &ip, outputString, sizeof(outputString));
+ folly::doNotOptimizeAway(val);
}
}
BENCHMARK_RELATIVE(ipv6_to_fully_qualified, iters) {
IPAddressV6 ip("F1E0:0ACE:FB94:7ADF:22E8:6DE6:9672:3725");
- string outputString;
while (iters--) {
- outputString = ip.toFullyQualified();
+ string outputString = ip.toFullyQualified();
+ folly::doNotOptimizeAway(outputString);
+ folly::doNotOptimizeAway(outputString.data());
}
}
ADD_FAILURE();
co_return x;
}();
+ (void)r2;
ADD_FAILURE();
} catch (/* nolint */ int i) {
EXPECT_EQ(42, i);
// This function will also initialize buf, which caller must free().
void createProtectedBuf(StringPiece& contents, char** buf) {
ASSERT_LE(contents.size(), kPageSize);
- const size_t kSuccess = 0;
char* pageAlignedBuf = (char*)aligned_malloc(2 * kPageSize, kPageSize);
if (pageAlignedBuf == nullptr) {
FAIL();
// There is implicit conversion from func pointer
// double (*)() to function<void()>.
ScopeGuard g = makeGuard(returnsDouble);
+ (void)g;
}
vector<int> v;
{
// binding to member function.
ScopeGuard g = makeGuard(std::bind(&vector<int>::pop_back, &v));
+ (void)g;
}
EXPECT_EQ(0, v.size());
{
// bind member function with args. v is passed-by-value!
ScopeGuard g = makeGuard(std::bind(push_back, v, 2));
+ (void)g;
}
EXPECT_EQ(0, v.size()); // push_back happened on a copy of v... fail!
// pass in an argument by pointer so to avoid copy.
{
ScopeGuard g = makeGuard(std::bind(push_back, &v, 4));
+ (void)g;
}
EXPECT_EQ(1, v.size());
{
// pass in an argument by reference so to avoid copy.
ScopeGuard g = makeGuard(std::bind(push_back, std::ref(v), 4));
+ (void)g;
}
EXPECT_EQ(2, v.size());
// lambda with a reference to v
{
ScopeGuard g = makeGuard([&] { v.push_back(5); });
+ (void)g;
}
EXPECT_EQ(3, v.size());
// lambda with a copy of v
{
ScopeGuard g = makeGuard([v] () mutable { v.push_back(6); });
+ (void)g;
}
EXPECT_EQ(3, v.size());
{
MyFunctor f(&n);
ScopeGuard g = makeGuard(f);
+ (void)g;
}
EXPECT_EQ(1, n);
n = 0;
{
ScopeGuard g = makeGuard(MyFunctor(&n));
+ (void)g;
}
EXPECT_EQ(1, n);
n = 2;
{
auto g = makeGuard(MyFunctor(&n));
+ (void)g;
}
EXPECT_EQ(3, n);
n = 10;
{
const auto& g = makeGuard(MyFunctor(&n));
+ (void)g;
}
EXPECT_EQ(11, n);
}
ScopeGuard g = makeGuard([&] {
throw std::runtime_error("destructors should never throw!");
});
+ (void)g;
},
"destructors should never throw!"
);
try {
ScopeGuard guard = makeGuard([&] { cleanupOccurred = true; });
+ (void)guard;
try {
if (error == ErrorBehavior::HANDLED_ERROR) {
~ThrowInDestructor() {
try {
InnerThrowInDestructor stackObjectThrowingOnUnwind;
+ (void)stackObjectThrowingOnUnwind;
Validator validator(
N - I + 1, "validating in " + folly::to<std::string>(I));
LOG(INFO) << "throwing in ~ThrowInDestructor " << I;
std::function<void()> fn(doNothing);
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard(fn);
+ (void)g;
}
}
BENCHMARK(scope_guard_std_function_rvalue, iters) {
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard(std::function<void()>(doNothing));
+ (void)g;
}
}
BENCHMARK(scope_guard_Function_rvalue, iters) {
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard(folly::Function<void()>(doNothing));
+ (void)g;
}
}
BENCHMARK(scope_guard_fn_ptr, iters) {
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard(doNothing);
+ (void)g;
}
}
BENCHMARK(scope_guard_lambda_noop, iters) {
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard([] {});
+ (void)g;
}
}
BENCHMARK(scope_guard_lambda_function, iters) {
for (size_t n = 0; n < iters; ++n) {
ScopeGuard g = makeGuard([] { doNothing(); });
+ (void)g;
}
}
++count;
}
});
+ (void)g;
}
// Check that the value of count is what we expect.
// but it also means we have some parameters that may not be used.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wunused-parameter")
+FOLLY_GCC_DISABLE_WARNING("-Wunused-variable")
using namespace std;
using namespace folly;
return true; \
auto f = test_ ## name <Vector, \
typename Vector::value_type, typename Vector::allocator_type>; \
+ (void)f; \
return true; \
} \
template <class Vector> bool test_I_ ## name ## 3 () { \