28 using namespace folly;
38 auto r = foomap.
insert(1, 0);
40 auto r2 = foomap.
insert(1, 0);
60 auto l = foomap.
find(1);
64 auto res = foomap.
find(2);
74 bool insert_failed =
false;
75 for (
int i = 0;
i < 32;
i++) {
76 auto res = foomap.
insert(0, 0);
143 auto res = foomap.
find(2);
145 if (res != foomap.
cend()) {
157 Uncopyable(
const Uncopyable& that) =
delete;
163 size_t operator()(
const Uncopyable&)
const {
170 auto res = foomap.
find(2);
175 auto res2 = foomap.
find(2);
177 EXPECT_EQ(&(res->second), &(res2->second));
196 size_t operator()(
const Movable&)
const {
215 auto res = foomap.
find(1);
232 auto iter = foomap.
cbegin();
244 for (
auto it = foomap.
cbegin(); it != foomap.
cend(); ++it) {
266 auto f1 = foomap.
find(1);
274 for (
auto cit = map.
cbegin(); cit != map.
cend(); ++cit) {
275 std::pair<int const, int>
const ckv{0, 0};
286 for (
auto it = foomap.
cbegin(); it != foomap.
cend();) {
287 if (it->second > 3) {
288 it = foomap.
erase(it);
294 for (
auto it = foomap.
cbegin(); it != foomap.
cend(); ++it) {
301 #define Atom std::atomic // DeterministicAtomic 302 #define Mutex std::mutex // DeterministicMutex 303 #define lib std // DeterministicSchedule 304 #define join t.join() // DeterministicSchedule::join(t) 314 unsigned size = 128 * 128;
315 unsigned iters =
size;
319 std::hash<unsigned long>,
320 std::equal_to<unsigned long>,
321 std::allocator<uint8_t>,
330 std::vector<std::thread>
threads;
331 unsigned int num_threads = 32;
333 threads.push_back(lib::thread([&,
t]() {
334 int offset = (iters *
t / num_threads);
335 for (
uint32_t i = 0;
i < iters / num_threads;
i++) {
337 k = k % (iters / num_threads) + offset;
338 unsigned long val = 3;
340 auto res = m.find(k);
343 auto r = m.assign(k, res->second);
347 auto res = m.find(k);
352 val = size +
i + offset;
357 for (
auto&
t : threads) {
366 unsigned iters = size * 128 * 2;
370 std::hash<unsigned long>,
371 std::equal_to<unsigned long>,
372 std::allocator<uint8_t>,
382 std::vector<std::thread>
threads;
383 unsigned int num_threads = 32;
385 threads.push_back(lib::thread([&,
t]() {
386 int offset = (iters *
t / num_threads);
387 for (
uint32_t i = 0;
i < iters / num_threads;
i++) {
389 auto res = m.insert(k, k).second;
393 printf(
"Faulre to erase thread %i val %li\n",
t, k);
398 res = m.insert(k, k).second;
400 res = bool(m.assign(k, k));
402 printf(
"Thread %i update fail %li res%i\n",
t, k, res);
406 auto result = m.find(k);
407 if (result == m.cend()) {
408 printf(
"Thread %i lookup fail %li\n",
t, k);
416 for (
auto&
t : threads) {
425 unsigned iters = size * 128 * 2;
429 std::hash<unsigned long>,
430 std::equal_to<unsigned long>,
431 std::allocator<uint8_t>,
444 std::vector<std::thread>
threads;
445 unsigned int num_threads = 32;
447 threads.push_back(lib::thread([&,
t]() {
448 int offset = (iters *
t / num_threads);
449 for (
uint32_t i = 0;
i < iters / num_threads;
i++) {
451 auto res = m.insert(k, k).second;
455 printf(
"Faulre to erase thread %i val %li\n",
t, k);
461 for (
auto it = m.cbegin(); it != m.cend(); ++it) {
462 printf(
"Item is %li\n", it->first);
463 if (it->first < 10) {
471 for (
auto&
t : threads) {
480 unsigned iters = size * 64 * 4;
484 std::hash<unsigned long>,
485 std::equal_to<unsigned long>,
486 std::allocator<uint8_t>,
494 std::vector<std::thread>
threads;
495 unsigned int num_threads = 32;
497 threads.push_back(lib::thread([&,
t]() {
498 int offset = (iters *
t / num_threads);
499 for (
uint32_t i = 0;
i < iters / num_threads;
i++) {
500 auto var = offset +
i + 1;
506 for (
auto&
t : threads) {
515 unsigned iters = size * 64 * 4;
526 v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 =
v;
542 std::hash<unsigned long>,
543 std::equal_to<unsigned long>,
544 std::allocator<uint8_t>,
556 std::vector<std::thread>
threads;
557 unsigned int num_threads = 32;
559 threads.push_back(lib::thread([&]() {
561 auto res = m.find(
i);
565 b.set(res->second.v1 + 1);
570 for (
auto&
t : threads) {
585 std::equal_to<uint64_t>,
586 std::allocator<uint8_t>,
612 map.
insert(0, std::make_shared<Wrapper>(del));
626 map.
insert(0, std::make_shared<Wrapper>(del));
641 map.
insert(0, std::make_shared<Wrapper>(del));
642 auto it = map.
find(0);
657 map.
insert(0, std::make_shared<Wrapper>(del));
658 for (
auto it = map.
cbegin(); it != map.
cend(); ++it) {
669 bool del1{
false}, del2{
false};
674 map.
insert(0, std::make_shared<Wrapper>(del1));
675 map.
insert(1, std::make_shared<Wrapper>(del2));
685 bool del1{
false}, del2{
false};
690 map.
insert(0, std::make_shared<Wrapper>(del1));
701 bool del1{
false}, del2{
false};
707 map1.
insert(0, std::make_shared<Wrapper>(del1));
708 map2.
insert(0, std::make_shared<Wrapper>(del2));
721 for (
const auto& kv : map) {
731 using Iter = CHM::ConstIterator;
735 Foo(Foo&&) =
default;
736 Foo& operator=(Foo&&) =
default;
742 Foo
foo(map.find(k));
744 Foo
foo2(map.find(0));
bool empty() const noexcept
#define ASSERT_EQ(val1, val2)
std::pair< ConstIterator, bool > try_emplace(Key &&k, Args &&...args)
ConstIterator cbegin() const noexcept
ConstIterator cend() const noexcept
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
folly::Optional< ConstIterator > assign(Key &&k, Value &&v)
FOLLY_NOINLINE void foo2()
auto begin(TestAdlIterable &instance)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
size_type erase(const key_type &k)
#define EXPECT_GE(val1, val2)
DEFINE_int64(threadtimeout_ms, 60000,"Idle time before ThreadPoolExecutor threads are joined")
const ValueType at(const KeyType &key) const
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
std::unordered_map< int64_t, VecT > Map
folly::Optional< ConstIterator > assign_if_equal(Key &&k, const ValueType &expected, Value &&desired)
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
static std::function< size_t(size_t)> uniform(uint64_t seed)
ConstIterator find(const KeyType &k) const
def Iter(n, format, sep='')
auto end(TestAdlIterable &instance)
static map< string, int > m
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
std::pair< ConstIterator, bool > emplace(Args &&...args)
folly::Singleton< int > bar
bool operator==(const MovableInt &a, const MovableInt &b)
TEST(ProgramOptionsTest, Errors)
#define EXPECT_TRUE(condition)
size_t size() const noexcept
#define EXPECT_NE(val1, val2)
void join(const Delim &delimiter, Iterator begin, Iterator end, String &output)
#define EXPECT_FALSE(condition)
void reserve(size_t count)
float max_load_factor() const
bool check(const dynamic &schema, const dynamic &value, bool check=true)
std::pair< ConstIterator, bool > insert_or_assign(Key &&k, Value &&v)
foo & operator=(const foo &)