April 2020
Intermediate to advanced
412 pages
9h 58m
English
We are implementing a simple Stack class that provides a constructor and a function named Push.
#include <atomic>#include <iostream>struct Node { int data; Node* next;};
class Stack { std::atomic<Node*> head; public: Stack() { std::cout << "Stack is " << (head.is_lock_free() ? "" : "not ") << "lock-free" << std::endl; } void Push(int data) { Node* new_node = new Node{data, ...