jamesge commented on a change in pull request #663: fix the comment; improve
code readability
URL: https://github.com/apache/incubator-brpc/pull/663#discussion_r270712787
##########
File path: src/butil/resource_pool_inl.h
##########
@@ -530,9 +532,10 @@ class BAIDU_CACHELINE_ALIGNMENT ResourcePool {
}
p->nfree = c.nfree;
memcpy(p->ids, c.ids, sizeof(*c.ids) * c.nfree);
- pthread_mutex_lock(&_free_chunks_mutex);
+
+ std::unique_lock<pthread_mutex_t> lock(_free_chunks_mutex);
_free_chunks.push_back(p);
- pthread_mutex_unlock(&_free_chunks_mutex);
+ lock.unlock();
Review comment:
用了unique_lock的话,return前的unlock都是没有必要的
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]