/* * Copyright 2018-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include DEFINE_bool(bench, false, "run benchmark"); DEFINE_int64(num_reps, 10, "Number of test reps"); DEFINE_int32(num_threads, 6, "Number of threads"); DEFINE_int64(num_ops, 1003, "Number of ops or pairs of ops per rep"); using folly::default_hazptr_domain; using folly::hazptr_array; using folly::hazptr_cleanup; using folly::hazptr_domain; using folly::hazptr_holder; using folly::hazptr_local; using folly::hazptr_obj_base; using folly::hazptr_obj_base_linked; using folly::hazptr_retire; using folly::hazptr_root; using folly::hazptr_tc; using folly::HazptrLockFreeLIFO; using folly::HazptrSWMRSet; using folly::HazptrWideCAS; using folly::test::Barrier; using folly::test::DeterministicAtomic; using DSched = folly::test::DeterministicSchedule; // Structures /** Count */ class Count { std::atomic ctors_{0}; std::atomic dtors_{0}; std::atomic retires_{0}; public: void clear() noexcept { ctors_.store(0); dtors_.store(0); retires_.store(0); } int ctors() const noexcept { return ctors_.load(); } int dtors() const noexcept { return dtors_.load(); } int retires() const noexcept { return retires_.load(); } void inc_ctors() noexcept { ctors_.fetch_add(1); } void inc_dtors() noexcept { dtors_.fetch_add(1); } void inc_retires() noexcept { retires_.fetch_add(1); } }; // Count static Count c_; /** Node */ template