x2c3z4 commented on a change in pull request #1669:
URL: https://github.com/apache/incubator-brpc/pull/1669#discussion_r790422706
##########
File path: src/bthread/mutex.h
##########
@@ -48,15 +48,15 @@ class Mutex {
Mutex() {
int ec = bthread_mutex_init(&_mutex, NULL);
if (ec != 0) {
- throw std::system_error(std::error_code(ec,
std::system_category()), "Mutex constructor failed");
+ CHECK(false) << "Mutex constructor failed";
}
}
~Mutex() { CHECK_EQ(0, bthread_mutex_destroy(&_mutex)); }
native_handler_type native_handler() { return &_mutex; }
void lock() {
int ec = bthread_mutex_lock(&_mutex);
if (ec != 0) {
- throw std::system_error(std::error_code(ec,
std::system_category()), "Mutex lock failed");
Review comment:
Google C++ code style suggests that don't use the c++ exception, and I
think a lot of projects have disabled the c++ exception including mine. All the
brpc code is worked with c++ no-exception, except this code snippet.
If we don't accept this error, just abort it.
As I know, if the mutex has been freed or is a bad memory address, the
pthread_mutex_lock will return EINVAL(22 Invalid argument). CHECK(false) is
better than c++ exception.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]