Mooophy / ftp-server

an FTP server written in C++11 and boost.
MIT License
5 stars 3 forks source link

unique_lock vs lock_guard #1

Open Mooophy opened 9 years ago

Mooophy commented 9 years ago

std::unique_lock vs std::lock_guard

pezy commented 9 years ago

std::unique_lock can always replace std::lock_gurad? IMO, std::unique_lock can only lock once at the constructor, and unlock at the destructor.

Mooophy commented 9 years ago

Not sure.. check line 27 and 34. It was not in a constructor, but works pretty well.

I found a few Q&A about them on SO, but no time to read, so just left a mark here for checking back later.

pezy commented 9 years ago

the only refer to once, not constructor. std::unique_lock is the common sense lock that we often talk about.

Mooophy commented 9 years ago

Oh .. I get you. I'm gonna try a little bit more to test them~