You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2019/04/01 04:17:50 UTC
[GitHub] [incubator-brpc] jamesge commented on a change in pull request
#663: fix the comment; improve code readability
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org