Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/applications/bmqbrkr/m_bmqbrkr_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <bmqma_countingallocator.h>
#include <bmqma_countingallocatorutil.h>
#include <bmqst_statcontext.h>
#include <bmqsys_threadutil.h>
#include <bmqtsk_alarmlog.h>
#include <bmqu_memoutstream.h>
#include <bmqu_printutil.h>
Expand All @@ -40,6 +39,7 @@
#include <bsl_memory.h>
#include <bslma_default.h>
#include <bslma_newdeleteallocator.h>
#include <bslmt_threadutil.h>
#include <bsls_types.h>

namespace BloombergLP {
Expand Down Expand Up @@ -193,7 +193,7 @@ int Task::onControlMessage(const bsl::string& message)

// Intercept the M-Trap to set the name of this PIPE CONTROL CHANNEL thread
if (bdlb::String::areEqualCaseless(message, k_MTRAP_SET_THREADNAME)) {
bmqsys::ThreadUtil::setCurrentThreadName("bmqPipeCtrl");
bslmt::ThreadUtil::setThreadName("bmqPipeCtrl");
return 0; // RETURN
}

Expand Down Expand Up @@ -281,7 +281,7 @@ int Task::initialize(bsl::ostream& errorDescription)

d_scheduler.scheduleEvent(
bsls::TimeInterval(0, 0), // now
bdlf::BindUtil::bind(&bmqsys::ThreadUtil::setCurrentThreadName,
bdlf::BindUtil::bind(&bslmt::ThreadUtil::setThreadName,
"bmqSchedTask"));

// -------------
Expand Down
4 changes: 1 addition & 3 deletions src/groups/bmq/bmqex/bmqex_sequentialcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

#include <bmqscm_version.h>

#include <bmqsys_threadutil.h>

// BDE
#include <bdlf_memfn.h>
#include <bsl_algorithm.h> // bsl::swap
Expand Down Expand Up @@ -109,7 +107,7 @@ SequentialContext::~SequentialContext()
// MANIPULATORS
int SequentialContext::start()
{
return start(bmqsys::ThreadUtil::defaultAttributes());
return start(bslmt::ThreadAttributes());
}

int SequentialContext::start(const bslmt::ThreadAttributes& threadAttributes)
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqex/bmqex_sequentialcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SequentialContext {
/// function objects on this execution context. Optionally specify a
/// `threadAttributes` used to configure the thread. If
/// `threadAttributes` is not provided, use the value of
/// `bmqsys::ThreadUtil::defaultAttributes()`. Return 0 on success, and
/// `bslmt::ThreadAttributes()`. Return 0 on success, and
/// a non-zero value otherwise. On failure this function has no effect.
/// The behavior is undefined unless 'threadAttributes.detachedState()
/// == bslmt::ThreadAttributes::e_CREATE_JOINABLE)', or if the working
Expand Down
5 changes: 1 addition & 4 deletions src/groups/bmq/bmqex/bmqex_systemexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
// // use the executor ...
//..

#include <bmqsys_threadutil.h>

// BDE
#include <bdlma_concurrentpoolallocator.h>
#include <bsl_memory.h>
Expand Down Expand Up @@ -555,8 +553,7 @@ inline void SystemExecutor::post(BSLS_COMPILERFEATURES_FORWARD_REF(FUNCTION)
{
SystemExecutor_Context::singleton().executeAsync(
BSLS_COMPILERFEATURES_FORWARD(FUNCTION, f),
d_threadAttributes ? *d_threadAttributes
: bmqsys::ThreadUtil::defaultAttributes());
d_threadAttributes ? *d_threadAttributes : bslmt::ThreadAttributes());
}

template <class FUNCTION>
Expand Down
4 changes: 1 addition & 3 deletions src/groups/bmq/bmqex/bmqex_systemexecutor.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
// TEST DRIVER
#include <bmqtst_testhelper.h>

#include <bmqsys_threadutil.h>

// BDE
#include <bdlf_bind.h>
#include <bsl_functional.h> // bsl::cref
Expand Down Expand Up @@ -155,7 +153,7 @@ static void test2_context_creators()
bdlf::BindUtil::bind(bslmt::ThreadUtil::setSpecific,
bsl::cref(tlsKey),
&threadsCompleted),
bmqsys::ThreadUtil::defaultAttributes());
bslmt::ThreadAttributes());
}

// destroy context singleton object
Expand Down
3 changes: 1 addition & 2 deletions src/groups/bmq/bmqimp/bmqimp_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <bmqscm_version.h>
#include <bmqst_statvalue.h>
#include <bmqst_tableutil.h>
#include <bmqsys_threadutil.h>
#include <bmqsys_time.h>
#include <bmqt_resultcode.h>
#include <bmqt_uri.h>
Expand Down Expand Up @@ -668,7 +667,7 @@ Application::Application(
// we can not call 'stop' on the scheduler from the 'finalizeCb', and
// 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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bslmt::ThreadAttributes attr = bslmt::ThreadAttributes();
bslmt::ThreadAttributes attr;

Possible to simplify

attr.setThreadName("bmqScheduler");
int rc = d_scheduler.start(attr);
if (rc != 0) {
Expand Down
11 changes: 5 additions & 6 deletions src/groups/bmq/bmqimp/bmqimp_brokersession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <bmqio_channel.h>
#include <bmqio_status.h>
#include <bmqst_statcontext.h>
#include <bmqsys_threadutil.h>
#include <bmqsys_time.h>
#include <bmqu_blob.h>
#include <bmqu_memoutstream.h>
Expand All @@ -64,6 +63,7 @@
#include <bslmt_mutexassert.h>
#include <bslmt_readlockguard.h>
#include <bslmt_semaphore.h>
#include <bslmt_threadutil.h>
#include <bsls_assert.h>
#include <bsls_performancehint.h>
#include <bsls_systemclocktype.h>
Expand Down Expand Up @@ -4772,8 +4772,8 @@ bool BrokerSession::appendOrSend(
.setFlags(qac.d_header.flags())
.setMessagePropertiesInfo(bmqp::MessagePropertiesInfo(qac.d_header));

BALL_LOG_DEBUG << "Adding PUT message for retransmission ["
<< "GUID: '" << builder.messageGUID() << "'] ";
BALL_LOG_DEBUG << "Adding PUT message for retransmission [" << "GUID: '"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

<< builder.messageGUID() << "'] ";

const bmqt::EventBuilderResult::Enum result = builder.packMessageRaw(
qac.d_queueId.id());
Expand Down Expand Up @@ -5765,8 +5765,7 @@ BrokerSession::BrokerSession(
resetState();

// Spawn the FSM thread
bslmt::ThreadAttributes threadAttributes =
bmqsys::ThreadUtil::defaultAttributes();
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes();
bslmt::ThreadAttributes threadAttributes;

Possible to simplify

threadAttributes.setThreadName("bmqFSMEvtQ");
if (bslmt::ThreadUtil::createWithAllocator(
&d_fsmThread,
Expand Down Expand Up @@ -5855,7 +5854,7 @@ void BrokerSession::setChannel(const bsl::shared_ptr<bmqio::Channel>& channel)
{
// executed by the *IO* thread

bmqsys::ThreadUtil::setCurrentThreadNameOnce("bmqTCPIO");
bslmt::ThreadUtil::setThreadName("bmqTCPIO");
Copy link
Collaborator

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;
    }
}


if (channel) { // We are now connected to bmqbrkr
BALL_LOG_INFO << id()
Expand Down
4 changes: 1 addition & 3 deletions src/groups/bmq/bmqimp/bmqimp_eventqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <bmqst_statcontext.h>
#include <bmqst_statutil.h>
#include <bmqst_tableutil.h>
#include <bmqsys_threadutil.h>
#include <bmqsys_time.h>
#include <bmqu_memoutstream.h>
#include <bmqu_printutil.h>
Expand Down Expand Up @@ -450,8 +449,7 @@ int EventQueue::start()
&bslma::ManagedPtr<bdlmt::FixedThreadPool>::reset,
&d_threadPool_mp));

bslmt::ThreadAttributes threadAttributes =
bmqsys::ThreadUtil::defaultAttributes();
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bslmt::ThreadAttributes threadAttributes = bslmt::ThreadAttributes();
bslmt::ThreadAttributes threadAttributes;

Possible to simplify

threadAttributes.setThreadName("bmqEventQueue");
d_threadPool_mp.load(new (*d_allocator_p)
bdlmt::FixedThreadPool(threadAttributes,
Expand Down
73 changes: 0 additions & 73 deletions src/groups/bmq/bmqsys/bmqsys_threadutil.cpp

This file was deleted.

78 changes: 0 additions & 78 deletions src/groups/bmq/bmqsys/bmqsys_threadutil.h

This file was deleted.

6 changes: 1 addition & 5 deletions src/groups/bmq/bmqsys/doc/bmqsys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ components to be reused through various applications.

/Hierarchical Synopsis
/---------------------
The 'bmqsys' package currently has 5 components having 2 levels of physical
The 'bmqsys' package currently has 4 components having 2 levels of physical
dependency. The list below shows the hierarchal ordering of the components.
..
2. bmqsys_mocktime
bmqsys_statmonitorsnapshotrecorder

1. bmqsys_statmonitor
bmqsys_threadutil
bmqsys_time
..

Expand All @@ -31,8 +30,5 @@ dependency. The list below shows the hierarchal ordering of the components.
: 'bmqsys_statmonitorsnapshotrecorder':
: Provide a mechanism to record snapshot of time, cpu, and ctx switch.
:
: 'bmqsys_threadutil':
: Provide utilities related to thread management.
:
: 'bmqsys_time':
: Provide a pluggable functional interface to system clocks.
1 change: 0 additions & 1 deletion src/groups/bmq/bmqsys/package/bmqsys.mem
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ bmqsys_mocktime
bmqsys_operationlogger
bmqsys_statmonitor
bmqsys_statmonitorsnapshotrecorder
bmqsys_threadutil
bmqsys_time
3 changes: 1 addition & 2 deletions src/groups/bmq/bmqtsk/bmqtsk_logcleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <bmqex_bindutil.h>
#include <bmqex_executionpolicy.h>
#include <bmqsys_threadutil.h>

// BDE
#include <ball_log.h>
Expand Down Expand Up @@ -55,7 +54,7 @@ bslmt::ThreadAttributes logsCleaningThreadAttributes()
// NOTE: Use low priority scheduling thread, since the log rotation
// operation is a background IO cleanup job.

bslmt::ThreadAttributes attr = bmqsys::ThreadUtil::defaultAttributes();
bslmt::ThreadAttributes attr = bslmt::ThreadAttributes();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bslmt::ThreadAttributes attr = bslmt::ThreadAttributes();
bslmt::ThreadAttributes attr;

Possible to simplify

attr.setInheritSchedule(false);
attr.setSchedulingPriority(
bslmt::ThreadUtil::getMinSchedulingPriority(attr.schedulingPolicy()));
Expand Down
4 changes: 1 addition & 3 deletions src/groups/bmq/bmqu/bmqu_atomicvalidator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// bmqu_atomicvalidator.t.cpp -*-C++-*-
#include <bmqu_atomicvalidator.h>

#include <bmqsys_threadutil.h>

// BDE
#include <bdlf_bind.h>
#include <bsl_iostream.h>
Expand Down Expand Up @@ -215,7 +213,7 @@ static void test2_atomicValidatorMultiThreaded()
for (int i = 0; i < k_NUM_THREADS; ++i) {
int ret = bslmt::ThreadUtil::createWithAllocator(
&handles[i],
bmqsys::ThreadUtil::defaultAttributes(),
bslmt::ThreadAttributes(),
bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(),
&acquireReleaseThread,
&validator,
Expand Down
Loading
Loading