-
Notifications
You must be signed in to change notification settings - Fork 154
Refactor[bmqsys]: Remove bmqsys_threadutil, use bslmt_threadutil instead #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor[bmqsys]: Remove bmqsys_threadutil, use bslmt_threadutil instead #989
Conversation
Remove bmqsys::ThreadUtil wrapper which duplicated bslmt::ThreadUtil functionality from BDE. Migrate all usages to bslmt::ThreadUtil and remove redundant files. Signed-off-by: MorganaFuture <[email protected]>
017ceaa
to
cfe98fb
Compare
@678098 I have added a signature. Could you please rerun CI/CD? |
@MorganaFuture thank you for the contribution! I will review the PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, it is mostly good.
The most important places are with setCurrentThreadOnce
, since the behaviour changed there
The rest of the comments are less important style/simplifications
// therefore have to let it stop in the application thread, i.e., from the | ||
// destructor of this object. | ||
bslmt::ThreadAttributes attr = bmqsys::ThreadUtil::defaultAttributes(); | ||
bslmt::ThreadAttributes attr = bslmt::ThreadAttributes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bslmt::ThreadAttributes attr = bslmt::ThreadAttributes(); | |
bslmt::ThreadAttributes attr; |
Possible to simplify
|
||
BALL_LOG_DEBUG << "Adding PUT message for retransmission [" | ||
<< "GUID: '" << builder.messageGUID() << "'] "; | ||
BALL_LOG_DEBUG << "Adding PUT message for retransmission [" << "GUID: '" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BALL_LOG_DEBUG << "Adding PUT message for retransmission [" << "GUID: '" | |
BALL_LOG_DEBUG << "Adding PUT message for retransmission [GUID: '" |
Since this line was affected, possible to simplify
// Spawn the FSM thread | ||
bslmt::ThreadAttributes threadAttributes = | ||
bmqsys::ThreadUtil::defaultAttributes(); | ||
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes(); | |
bslmt::ThreadAttributes threadAttributes; |
Possible to simplify
// executed by the *IO* thread | ||
|
||
bmqsys::ThreadUtil::setCurrentThreadNameOnce("bmqTCPIO"); | ||
bslmt::ThreadUtil::setThreadName("bmqTCPIO"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the behaviour changed.
Previously the thread name was set only once in each thread.
Now it is changed every time this function is executed.
I would propose to put setCurrentThreadOnce
to unnamed namespace in this .cpp
file and call it here. This way, we still get rid of bmqsys::ThreadUtil
.
void setCurrentThreadNameOnce(const bsl::string& value)
{
#ifdef BSLS_PLATFORM_CMP_CLANG
// Suppress "exit-time-destructor" warning on Clang by qualifying the
// static variable 's_named' with Clang-specific attribute.
[[clang::no_destroy]]
#endif
static bmqu::TLSBool s_named(false, true);
if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!s_named)) {
BSLS_PERFORMANCEHINT_UNLIKELY_HINT;
setCurrentThreadName(value);
s_named = true;
}
}
|
||
bslmt::ThreadAttributes threadAttributes = | ||
bmqsys::ThreadUtil::defaultAttributes(); | ||
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes(); | |
bslmt::ThreadAttributes threadAttributes; |
Possible to simplify
|
||
bslmt::ThreadAttributes attributes = | ||
bmqsys::ThreadUtil::defaultAttributes(); | ||
bslmt::ThreadAttributes attributes = bslmt::ThreadAttributes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bslmt::ThreadAttributes attributes = bslmt::ThreadAttributes(); | |
bslmt::ThreadAttributes attributes; |
Possible to simplify
BALL_LOG_WARN << "#TCP_UNEXPECTED_STATE " | ||
<< "TCPSessionFactory '" << d_config.name() | ||
<< "' is not listening"; | ||
BALL_LOG_WARN << "#TCP_UNEXPECTED_STATE " << "TCPSessionFactory '" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BALL_LOG_WARN << "#TCP_UNEXPECTED_STATE " << "TCPSessionFactory '" | |
BALL_LOG_WARN << "#TCP_UNEXPECTED_STATE TCPSessionFactory '" |
BALL_LOG_ERROR << "#TCP_LISTEN_FAILED " << "TCPSessionFactory '" | ||
<< d_config.name() << "' " << "failed listening to '" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BALL_LOG_ERROR << "#TCP_LISTEN_FAILED " << "TCPSessionFactory '" | |
<< d_config.name() << "' " << "failed listening to '" | |
BALL_LOG_ERROR << "#TCP_LISTEN_FAILED TCPSessionFactory '" | |
<< d_config.name() << "' failed listening to '" |
BALL_LOG_ERROR << "#TCP_CONNECT_FAILED " << "TCPSessionFactory '" | ||
<< d_config.name() << "' " << "failed connecting to '" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BALL_LOG_ERROR << "#TCP_CONNECT_FAILED " << "TCPSessionFactory '" | |
<< d_config.name() << "' " << "failed connecting to '" | |
BALL_LOG_ERROR << "#TCP_CONNECT_FAILED TCPSessionFactory '" | |
<< d_config.name() << "' failed connecting to '" |
// is fine to do this here (since we have no other ways to | ||
// proactively-execute code in the IO threads created by the channelPool). | ||
bmqsys::ThreadUtil::setCurrentThreadNameOnce(d_threadName); | ||
bslmt::ThreadUtil::setThreadName(d_threadName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the same comment as with bmqimp_brokersession
The behaviour changed, a good way to solve this is to put a copy of setCurrentThreadNameOnce
in the unnamed namespace in this .cpp
file
Fixes Ticket 950
Remove bmqsys::ThreadUtil wrapper which duplicated bslmt::ThreadUtil functionality from BDE. Migrate all usages to bslmt::ThreadUtil and remove redundant files.
Testing
ctest -R "bmqsys|bmqimp|mqbnet"