Skip to content

Commit cc46683

Browse files
committed
Fix: Remove all uses of bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME
The contracts of `bmqsys::ThreadUtil::setCurrentThreadName` and `bmqsys::ThreadUtil::setCurrentThreadNameOnce` are wide; they may be called on any platform, and they have no side effects on platforms where setting a thread name is unsupported. This means we do not need to guard calls to them by checking a constant that is only true on platforms where setting a thread name is supported. This patch removes all such guards, which removes all uses of this constant. In most cases, the use of this constant is in an `if` statement that obviously wraps some call to `bmqsys::ThreadUtil::setCurrentThreadName` or `bmqsys::ThreadUtil::setCurrentThreadNameOnce`. The only less obvious case is in `m_bmqbrkr_task`’s mtrap support, where this constant guards a write of the command `k_MTRAP_SET_THREADNAME` to the mtrap pipe. The command is handled by `Task::onControlMessage` in the same file, which in turn calls `bmqsys::ThreadUtil::setCurrentThreadName`. Presumably, this is where the `if` guard should have been, but now it is safe to remove the guard on the write. Signed-off-by: Patrick M. Niedzielski <[email protected]>
1 parent f792240 commit cc46683

File tree

6 files changed

+26
-41
lines changed

6 files changed

+26
-41
lines changed

src/applications/bmqbrkr/m_bmqbrkr_task.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,10 @@ int Task::initialize(bsl::ostream& errorDescription)
279279
return rc_SCHEDULER_START_FAILED; // RETURN
280280
}
281281

282-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
283-
d_scheduler.scheduleEvent(
284-
bsls::TimeInterval(0, 0), // now
285-
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
286-
"bmqSchedTask"));
287-
}
282+
d_scheduler.scheduleEvent(
283+
bsls::TimeInterval(0, 0), // now
284+
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
285+
"bmqSchedTask"));
288286

289287
// -------------
290288
// LogController
@@ -344,10 +342,7 @@ int Task::initialize(bsl::ostream& errorDescription)
344342
return rc_CONTROLCHANNEL_START_FAILED; // RETURN
345343
}
346344

347-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
348-
bdls::PipeUtil::send(pipePath,
349-
bsl::string(k_MTRAP_SET_THREADNAME) + "\n");
350-
}
345+
bdls::PipeUtil::send(pipePath, bsl::string(k_MTRAP_SET_THREADNAME) + "\n");
351346

352347
// -------------------
353348
// M-Trap registration

src/groups/bmq/bmqimp/bmqimp_brokersession.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -5850,9 +5850,7 @@ void BrokerSession::setChannel(const bsl::shared_ptr<bmqio::Channel>& channel)
58505850
{
58515851
// executed by the *IO* thread
58525852

5853-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
5854-
bmqsys::ThreadUtil::setCurrentThreadNameOnce("bmqTCPIO");
5855-
}
5853+
bmqsys::ThreadUtil::setCurrentThreadNameOnce("bmqTCPIO");
58565854

58575855
if (channel) { // We are now connected to bmqbrkr
58585856
BALL_LOG_INFO << "Channel is CREATED [host: " << channel->peerUri()

src/groups/mqb/mqba/mqba_dispatcher.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -522,17 +522,15 @@ int Dispatcher::start(bsl::ostream& errorDescription)
522522
return rc; // RETURN
523523
}
524524

525-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
526-
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
527-
"bmqDispSession"),
528-
mqbi::DispatcherClientType::e_SESSION);
529-
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
530-
"bmqDispQueue"),
531-
mqbi::DispatcherClientType::e_QUEUE);
532-
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
533-
"bmqDispCluster"),
534-
mqbi::DispatcherClientType::e_CLUSTER);
535-
}
525+
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
526+
"bmqDispSession"),
527+
mqbi::DispatcherClientType::e_SESSION);
528+
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
529+
"bmqDispQueue"),
530+
mqbi::DispatcherClientType::e_QUEUE);
531+
execute(bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
532+
"bmqDispCluster"),
533+
mqbi::DispatcherClientType::e_CLUSTER);
536534

537535
d_isStarted = true;
538536

src/groups/mqb/mqbnet/mqbnet_elector.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -2234,15 +2234,13 @@ Elector::Elector(mqbcfg::ElectorConfig& config,
22342234

22352235
d_state.setTerm(initialTerm);
22362236

2237-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
2238-
// Per scheduler's contract, it's ok to schedule events before its
2239-
// started.
2237+
// Per scheduler's contract, it's ok to schedule events before its
2238+
// started.
22402239

2241-
d_scheduler.scheduleEvent(
2242-
bsls::TimeInterval(0, 0), // now
2243-
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
2244-
"bmqSchedElec"));
2245-
}
2240+
d_scheduler.scheduleEvent(
2241+
bsls::TimeInterval(0, 0), // now
2242+
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
2243+
"bmqSchedElec"));
22462244
}
22472245

22482246
Elector::~Elector()

src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,7 @@ void TCPSessionFactory::channelStateCallback(
656656
// This is an infrequent enough operation (compared to a 'readCb') that it
657657
// is fine to do this here (since we have no other ways to
658658
// proactively-execute code in the IO threads created by the channelPool).
659-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
660-
bmqsys::ThreadUtil::setCurrentThreadNameOnce(d_threadName);
661-
}
659+
bmqsys::ThreadUtil::setCurrentThreadNameOnce(d_threadName);
662660

663661
BALL_LOG_TRACE << "TCPSessionFactory '" << d_config.name()
664662
<< "': channelStateCallback [event: " << event

src/groups/mqb/mqbstat/mqbstat_statcontroller.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -725,12 +725,10 @@ int StatController::start(bsl::ostream& errorDescription)
725725
return -2; // RETURN
726726
}
727727

728-
if (bmqsys::ThreadUtil::k_SUPPORT_THREAD_NAME) {
729-
d_scheduler_mp->scheduleEvent(
730-
bsls::TimeInterval(0), // execute as soon as possible
731-
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
732-
"bmqSchedStat"));
733-
}
728+
d_scheduler_mp->scheduleEvent(
729+
bsls::TimeInterval(0), // execute as soon as possible
730+
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
731+
"bmqSchedStat"));
734732

735733
// Create and start the system stat monitor. The SystemStats are used in
736734
// the dashboard screen, stat consumers, stats printer, ... So we need to

0 commit comments

Comments
 (0)