The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

482318 (4) [Avatar] Offline
#1
in Listing 7.9 A lock-free stack using a lock-free std::shared_ptr<> implementation, the push member function contains
new_node->next = head.load()
, should it be
new_node->next = std::atomic_load(&head)
, cause i can't find load member function in std::shared_ptr.


in Listing 7.10 A lock-free stack using a lock-free std::experimental::atomic_shared_ptr<> implementation. in struct node definition
struct node     {         
    std::atomic_shared_ptr<T> data;         
    std::experimental::atomic_shared_ptr<node> next;         
    node(T const& data_): data(std::make_shared<T>(data_)) {}    
 }; 


should std::atomic_shared_ptr<T> data be std::shared_ptr<T>? cause std namespace don't have atomic_shared_ptr, and it's not necessary to hold data using atomic pointer.


if i misunderstand, please let me know.
anthony.williams (216) [Avatar] Offline
#2
Fixed.