template class threadsafe_queue { private: struct node { std::shared_ptr data; std::unique_ptr next; }; std::mutex head_mutex; std::unique_ptr head; std::mutex tail_mutex; node* tail; std::condition_variable data_cond; public: threadsafe_queue(): head(new node),tail(head.get()) {} threadsafe_queue(const threadsafe_queue& other)=delete; threadsafe_queue& operator=(const threadsafe_queue& other)=delete; std::shared_ptr try_pop(); bool try_pop(T& value); std::shared_ptr wait_and_pop(); void wait_and_pop(T& value); void push(T new_value); void empty(); };