28 struct alignas(hardware_destructive_interference_size)
Line {
35 x_ = std::make_unique<Line[]>(size_);
40 for (
size_t i = 1;
i < size_; ++
i) {
41 assert(
x_[
i].val_ == val);
50 for (
size_t i = 0;
i < size_; ++
i) {
51 assert(
x_[
i].val_ == oldval);
58 for (
size_t i = 0;
i < size_; ++
i) {
59 assert(
x_[
i].val_ == res);
67 std::unique_ptr<Line[]>
x_;
74 template <
typename>
class Atom = std::atomic>
76 :
public FlatCombining<FcSimpleExample<Mutex, Atom>, Mutex, Atom> {
78 using Rec =
typename FC::Rec;
89 return data_.getVal();
95 this->requestNoFC([&] {
data_.add(val); });
99 auto opFn = [&,
val] {
102 this->requestFC(opFn, rec,
false);
109 auto opFn = [&] { res =
data_.fetchAdd(val); };
110 this->requestNoFC(opFn);
116 auto opFn = [&] { res =
data_.fetchAdd(val); };
117 this->requestFC(opFn, rec);
129 enum class Type { ADD, FETCHADD };
164 template <
typename>
class Atom = std::atomic>
166 FcCustomExample<Req, Mutex, Atom>,
171 using Rec =
typename FC::Rec;
182 return data_.getVal();
188 this->requestNoFC([&] {
data_.add(val); });
192 auto opFn = [&,
val] {
data_.add(val); };
193 auto fillFn = [&](Req& req) {
197 this->requestFC(opFn, fillFn, rec,
false);
204 auto opFn = [&] { res =
data_.fetchAdd(val); };
205 this->requestNoFC(opFn);
211 auto opFn = [&] { res =
data_.fetchAdd(val); };
212 auto fillFn = [&](Req& req) {
216 auto resFn = [&](Req& req) { res = req.getRes(); };
217 this->requestFC(opFn, fillFn, resFn, rec);
void combinedOp(Req &req)
uint64_t fetchAddNoFC(uint64_t val)
std::unique_ptr< Line[]> x_
uint64_t fetchAddNoFC(uint64_t val)
—— Concurrent Priority Queue Implementation ——
uint64_t fetchAdd(uint64_t val, Rec *rec=nullptr)
FcSimpleExample(size_t size, bool dedicated=true, uint32_t numRecs=0, uint32_t maxOps=0)
constexpr auto size(C const &c) -> decltype(c.size())
FOLLY_ALWAYS_INLINE void assume_unreachable()
uint64_t fetchAdd(uint64_t val, Rec *rec=nullptr)
void add(uint64_t val, Rec *rec=nullptr)
void setVal(uint64_t val)
void addNoFC(uint64_t val)
FcCustomExample(int size, bool dedicated=true, uint32_t numRecs=0, uint32_t maxOps=0)
void addNoFC(uint64_t val)
void add(uint64_t val, Rec *rec=nullptr)
void setRes(uint64_t res)
uint64_t fetchAdd(uint64_t val)