Commit 8042bf57 authored by Miroslav Crnic's avatar Miroslav Crnic Committed by Facebook Github Bot

LifoSem make tryRemoveNode protected

Summary:
Lifo sem exposes allocateNode and tryWaitOrPush as protected which allows inherited classes custom Node implementation, creation and enqueueing.
tryRemoveNode was private which prevented inherited classes from dequeueing a Node without signaling shutdown.
This diff fixes it

Reviewed By: shixiao

Differential Revision: D15647287

fbshipit-source-id: 5b26a9616f6de559224f9d8c38230780c78a7cf5
parent d3233089
......@@ -594,18 +594,6 @@ struct LifoSemBase {
return decrOrPush(n, nodeToIdx(waiterNode));
}
private:
CachelinePadded<folly::AtomicStruct<LifoSemHead, Atom>> head_;
static LifoSemNode<Handoff, Atom>& idxToNode(uint32_t idx) {
auto raw = &LifoSemRawNode<Atom>::pool()[idx];
return *static_cast<LifoSemNode<Handoff, Atom>*>(raw);
}
static uint32_t nodeToIdx(const LifoSemNode<Handoff, Atom>& node) {
return LifoSemRawNode<Atom>::pool().locateElem(&node);
}
// Locks the list head (blocking concurrent pushes and pops)
// and attempts to remove this node. Returns true if node was
// found and removed, false if not found.
......@@ -660,6 +648,18 @@ struct LifoSemBase {
return result;
}
private:
CachelinePadded<folly::AtomicStruct<LifoSemHead, Atom>> head_;
static LifoSemNode<Handoff, Atom>& idxToNode(uint32_t idx) {
auto raw = &LifoSemRawNode<Atom>::pool()[idx];
return *static_cast<LifoSemNode<Handoff, Atom>*>(raw);
}
static uint32_t nodeToIdx(const LifoSemNode<Handoff, Atom>& node) {
return LifoSemRawNode<Atom>::pool().locateElem(&node);
}
/// Either increments by n and returns 0, or pops a node and returns it.
/// If n + the stripe's value overflows, then the stripe's value
/// saturates silently at 2^32-1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment