In the book "C++ Concurrency in Action" reading the following method
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()!=get_tail();});
return std::move(head_lock);
}
I cannot understand why the head_lock is std::move-ed when returned. My notion and gut feeling of the move usage and RVO matches the opinion shared in C++11 rvalues and move semantics confusion (return statement)
But I kind of tend to trust the author to know better. Can someone clarify when std::move the return value is better and is there something specifically about the locks? Thanks.