blob: 899a082f3382adea60c32fbbfe625582d7476136 (
plain) (
tree)
|
|
#ifndef _SALTICIDAE_QUEUE_H
#define _SALTICIDAE_QUEUE_H
#include <atomic>
#include <vector>
#include <cassert>
#include <thread>
namespace salticidae {
static size_t const cacheline_size = 64;
using cacheline_pad = uint8_t[cacheline_size];
class FreeList {
public:
struct Node {
std::atomic<Node *> next;
std::atomic<size_t> refcnt;
std::atomic<bool> freed;
Node(): next(nullptr), refcnt(1), freed(false) {}
virtual ~Node() {}
};
private:
std::atomic<Node *> top;
public:
FreeList(): top(nullptr) {}
FreeList(const FreeList &) = delete;
FreeList(FreeList &&) = delete;
void release_ref(Node *u) {
if (u->refcnt.fetch_sub(1,<
|