32 typedef std::function<void()> Task;
44 void Post(Task&& task);
58 typedef uint64_t TagAndIndex;
65 Node(
const Node& node) : next() {}
68 LocklessTaskQueue::Task task;
71 std::atomic<TagAndIndex> next;
75 TagAndIndex IncreaseTag(TagAndIndex tag_and_index);
78 TagAndIndex GetIndex(TagAndIndex tag_and_index);
81 TagAndIndex GetFlag(TagAndIndex tag_and_index);
87 void PushNodeToList(std::atomic<TagAndIndex>* list_head, TagAndIndex node);
93 TagAndIndex PopNodeFromList(std::atomic<TagAndIndex>* list_head);
100 void ProcessTaskList(TagAndIndex list_head,
bool execute);
105 void Init(
size_t num_nodes);
108 std::atomic<TagAndIndex> free_list_head_idx_;
111 std::atomic<TagAndIndex> task_list_head_idx_;
114 std::vector<Node> nodes_;
118 std::vector<Task> temp_tasks_;