条件变量的这种用法是错误的吗?

oli*_*ist 6 c++ concurrency multithreading condition-variable

C++ Concurrency in Action的第6章,它实现了一个线程安全的队列.是完整的代码.但我发现使用条件变量可能有问题.

  std::unique_lock<std::mutex> wait_for_data()
  {
    std::unique_lock<std::mutex> head_lock(head_mutex);
    data_cond.wait(head_lock, [&] {return head.get() != queue::get_tail(); });
    return std::move(head_lock);
  }

  void push(T new_value)
  {
    std::shared_ptr<T> new_data(
      std::make_shared<T>(std::move(new_value)));
    std::unique_ptr<node> p(new node);
    {
      std::lock_guard<std::mutex> tail_lock(tail_mutex);
      tail->data = new_data;
      node *const new_tail = p.get();
      tail->next = std::move(p);
      tail = new_tail;
    }
    data_cond.notify_one();
  }
Run Code Online (Sandbox Code Playgroud)

消耗部件锁定head_mutex,但生产部件锁定tail_mutex,可能导致消费者错过通知.我好吗?