Closed JohnGu9 closed 4 years ago
I don't see the problem with unique_lock
here. Can you expand on to why you think it is wrong?
Sorry, I find out it is my mistake that sometimes my task will be blocked by system api :( unique_lock is work fine. Maybe lock_guard is lightweight that toggle my mistake less times somehow.
origin code
In the 13nd line
std::unique_lock<std::mutex> lock(queue_mutex);
This code seem to be an invaild lock that lead to task can't run after push back into queue.I change this a bit.
std::lock_guard<std::mutex> lock(queue_mutex);
and work properly.