Skip to content

Commit

Permalink
Merge pull request ceph#42826 from tchaikov/wip-test-fair-mutex
Browse files Browse the repository at this point in the history
test/common/test_fair_mutex: increase NR_ROUNDS from 256 to 512

Reviewed-by: Patrick Donnelly <[email protected]>
  • Loading branch information
tchaikov authored Aug 24, 2021
2 parents 60811bf + ab3dc08 commit 56bf728
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/test/common/test_fair_mutex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <array>
#include <mutex>
#include <numeric>
#include <thread>
#include <future>
#include <gtest/gtest.h>
#include "common/fair_mutex.h"

Expand Down Expand Up @@ -34,7 +34,7 @@ TEST(FairMutex, fair)
ceph::fair_mutex mutex{"fair::fair"};
const int NR_TEAMS = 2;
std::array<unsigned, NR_TEAMS> scoreboard{0, 0};
const int NR_ROUNDS = 256;
const int NR_ROUNDS = 512;
auto play = [&](int team) {
for (int i = 0; i < NR_ROUNDS; i++) {
std::unique_lock lock{mutex};
Expand All @@ -61,11 +61,8 @@ TEST(FairMutex, fair)
};
}
};
std::array<std::thread, NR_TEAMS> teams;
std::array<std::future<void>, NR_TEAMS> completed;
for (int team = 0; team < NR_TEAMS; team++) {
teams[team] = std::thread(play, team);
}
for (auto& team : teams) {
team.join();
completed[team] = std::async(std::launch::async, play, team);
}
}

0 comments on commit 56bf728

Please sign in to comment.