Skip to content

Commit 3ebd5bf

Browse files
authored
Cleanup[bmqu::OperationChain]: remove cpp03 autogenerated code (bloomberg#1531)
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
1 parent df0547b commit 3ebd5bf

5 files changed

Lines changed: 30 additions & 1391 deletions

File tree

src/groups/bmq/bmqu/bmqu_operationchain.h

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@
101101
// typedef bsl::function<void()>
102102
// SendCallback;
103103
//
104-
// typedef bsl::function<void(int clientId, int payload)>
104+
// typedef bsl::function<void()>
105105
// ReceiveCallback;
106106
//
107107
// // CLASS FUNCTIONS
108108
// static void onDataSent();
109109
// // Callback invoked on completion of a 'send' operation.
110110
//
111-
// static void onDataReceived(int clientId, int payload);
111+
// static void onDataReceived();
112112
// // Callback invoked on completion of a 'receive' operation.
113113
//
114114
// static void send(int clientId,
@@ -119,9 +119,8 @@
119119
// // 'completionCallback' when the payload is sent.
120120
//
121121
// static void receive(const ReceiveCallback& completionCallback);
122-
// // Receive a payload send to us by another client and invoke the
123-
// // specified 'completionCallback' with the payload and the sender
124-
// // client ID.
122+
// // Receive a payload from another client and invoke the specified
123+
// // 'completionCallback' when done.
125124
// };
126125
//..
127126
// Lets say we want to "receive" data from 10 clients, and then "send" data
@@ -188,15 +187,6 @@
188187
#include <bsl_type_traits.h>
189188
#endif
190189

191-
#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
192-
// Include version that can be compiled with C++03
193-
// Generated on Wed Jun 18 14:44:06 2025
194-
// Command line: sim_cpp11_features.pl bmqu_operationchain.h
195-
# define COMPILING_BMQU_OPERATIONCHAIN_H
196-
# include <bmqu_operationchain_cpp03.h>
197-
#undef COMPILING_BMQU_OPERATIONCHAIN_H
198-
#else
199-
200190
namespace BloombergLP {
201191

202192
namespace bmqu {
@@ -299,14 +289,11 @@ class OperationChain_CompletionCallbackWrapper {
299289

300290
public:
301291
// ACCESSORS
302-
#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9
303292

304-
/// Invoke the associated completion callback with the specified `args`
305-
/// arguments and notify the associated operation chain. Propagate any
306-
/// exception thrown by the completion callback to the caller.
307-
template <class... ARGS>
308-
void operator()(ARGS&&... args) const;
309-
#endif
293+
/// Invoke the associated completion callback and notify the associated
294+
/// operation chain. Propagate any exception thrown by the completion
295+
/// callback to the caller.
296+
void operator()() const;
310297

311298
// TRAITS
312299
BSLMF_NESTED_TRAIT_DECLARATION(OperationChain_CompletionCallbackWrapper,
@@ -795,27 +782,20 @@ inline OperationChain_CompletionCallbackWrapper<CO_CALLBACK>::
795782
}
796783

797784
// ACCESSORS
798-
#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9
799785
template <class CO_CALLBACK>
800-
template <class... ARGS>
801-
inline void OperationChain_CompletionCallbackWrapper<CO_CALLBACK>::operator()(
802-
ARGS&&... args) const
786+
inline void
787+
OperationChain_CompletionCallbackWrapper<CO_CALLBACK>::operator()() const
803788
{
804789
try {
805-
// invoke completion callback
806-
bslmf::Util::moveIfSupported((*d_coCallback_p))(
807-
bslmf::Util::forward<ARGS>(args)...);
790+
bslmf::Util::moveIfSupported((*d_coCallback_p))();
808791
}
809792
catch (...) {
810-
// notify the chain and rethrow the exception
811793
d_chain_p->onOperationCompleted(d_jobHandle);
812794
throw; // THROW
813795
}
814796

815-
// notify the chain
816797
d_chain_p->onOperationCompleted(d_jobHandle);
817798
}
818-
#endif
819799

820800
// ------------------------
821801
// class OperationChain_Job
@@ -1010,6 +990,4 @@ inline void bmqu::swap(OperationChainLink& lhs,
1010990

1011991
} // close enterprise namespace
1012992

1013-
#endif // End C++11 code
1014-
1015993
#endif

src/groups/bmq/bmqu/bmqu_operationchain.t.cpp

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,6 @@ void asyncNullOperation(bdlmt::ThreadPool* threadPool,
5959
threadPool->enqueueJob(callback);
6060
}
6161

62-
/// Invoke the specified completion `callback` on the specified `threadPool`
63-
/// with the specified `operationId` parameter.
64-
void asyncIdentifiableOperation(bdlmt::ThreadPool* threadPool,
65-
unsigned operationId,
66-
const bsl::function<void(unsigned)>& callback)
67-
{
68-
// PRECONDITIONS
69-
BSLS_ASSERT(threadPool);
70-
BSLS_ASSERT(callback);
71-
72-
threadPool->enqueueJob(bdlf::BindUtil::bind(callback, operationId));
73-
}
74-
7562
/// Return a `bsls::TimeInterval` object encoding a point in time the
7663
/// specified number of `seconds` from now, according to the monotonic
7764
/// clock.
@@ -241,25 +228,24 @@ struct UsageExample {
241228
// TYPES
242229
typedef bsl::function<void()> SendCallback;
243230

244-
typedef bsl::function<void(int clientId, int payload)> ReceiveCallback;
231+
typedef bsl::function<void()> ReceiveCallback;
245232

246233
// CLASS FUNCTIONS
247234

248235
/// Callback invoked on completion of a `send` operation.
249236
static void onDataSent();
250237

251238
/// Callback invoked on completion of a `receive` operation.
252-
static void onDataReceived(int clientId, int payload);
239+
static void onDataReceived();
253240

254241
/// Send the specified `payload` to the client identified by the
255242
/// specified `clientId` and invoke the specified
256243
/// `completionCallback` when the payload is sent.
257244
static void
258245
send(int clientId, int payload, const SendCallback& completionCallback);
259246

260-
/// Receive a payload send to us by another client and invoke the
261-
/// specified `completionCallback` with the payload and the sender
262-
/// client ID.
247+
/// Receive a payload from another client and invoke the specified
248+
/// `completionCallback` when done.
263249
static void receive(const ReceiveCallback& completionCallback);
264250
};
265251

@@ -273,7 +259,7 @@ inline void UsageExample::onDataSent()
273259
// NOTHING
274260
}
275261

276-
inline void UsageExample::onDataReceived(int, int)
262+
inline void UsageExample::onDataReceived()
277263
{
278264
// NOTHING
279265
}
@@ -286,7 +272,7 @@ UsageExample::send(int, int, const SendCallback& completionCallback)
286272

287273
inline void UsageExample::receive(const ReceiveCallback& completionCallback)
288274
{
289-
completionCallback(0, 0);
275+
completionCallback();
290276
}
291277

292278
// ============================================================================
@@ -412,13 +398,10 @@ static void test3_chain_startStop(bdlmt::ThreadPool* threadPool)
412398
for (unsigned operationId = 0; operationId < k_NUM_OPERATIONS;
413399
++operationId) {
414400
chain.appendInplace(
415-
bdlf::BindUtil::bind(&asyncIdentifiableOperation,
401+
bdlf::BindUtil::bind(&asyncNullOperation,
416402
threadPool,
417-
operationId,
418403
bdlf::PlaceHolders::_1),
419-
bdlf::BindUtil::bind(PushBack(),
420-
&completionIds,
421-
bdlf::PlaceHolders::_1));
404+
bdlf::BindUtil::bind(PushBack(), &completionIds, operationId));
422405
}
423406

424407
// make sure operation haven't started executing
@@ -458,15 +441,13 @@ static void test3_chain_startStop(bdlmt::ThreadPool* threadPool)
458441
// add several operations
459442
for (unsigned operationId = 0; operationId < k_NUM_OPERATIONS;
460443
++operationId) {
461-
chain.appendInplace(
462-
bdlf::BindUtil::bind(&asyncIdentifiableOperation,
463-
threadPool,
464-
operationId,
465-
bdlf::PlaceHolders::_1),
466-
bdlf::BindUtil::bind(PushBackSynchronize(),
467-
&semaphore,
468-
&completionIds,
469-
bdlf::PlaceHolders::_1));
444+
chain.appendInplace(bdlf::BindUtil::bind(&asyncNullOperation,
445+
threadPool,
446+
bdlf::PlaceHolders::_1),
447+
bdlf::BindUtil::bind(PushBackSynchronize(),
448+
&semaphore,
449+
&completionIds,
450+
operationId));
470451
}
471452

472453
// no executing operations
@@ -524,13 +505,12 @@ static void test4_chain_join(bdlmt::ThreadPool* threadPool)
524505
// add several operations
525506
for (unsigned operationId = 0; operationId < k_NUM_OPERATIONS;
526507
++operationId) {
527-
chain.appendInplace(bdlf::BindUtil::bind(&asyncIdentifiableOperation,
508+
chain.appendInplace(bdlf::BindUtil::bind(&asyncNullOperation,
528509
threadPool,
529-
operationId,
530510
bdlf::PlaceHolders::_1),
531511
bdlf::BindUtil::bind(PushBackRndSleep(),
532512
&completionIds,
533-
bdlf::PlaceHolders::_1));
513+
operationId));
534514
}
535515

536516
// start executing
@@ -1102,13 +1082,12 @@ static void test10_chain_serialization(bdlmt::ThreadPool* threadPool)
11021082
for (unsigned i = 0; i < k_NUM_LINKS; ++i) {
11031083
for (unsigned j = 0; j < k_NUM_OPERATIONS; ++j) {
11041084
unsigned operationId = i * k_NUM_OPERATIONS + j;
1105-
link.insert(bdlf::BindUtil::bind(&asyncIdentifiableOperation,
1085+
link.insert(bdlf::BindUtil::bind(&asyncNullOperation,
11061086
threadPool,
1107-
operationId,
11081087
bdlf::PlaceHolders::_1),
11091088
bdlf::BindUtil::bind(PushBackRndSleep(),
11101089
&completionIds,
1111-
bdlf::PlaceHolders::_1));
1090+
operationId));
11121091
}
11131092

11141093
chain.append(&link);

src/groups/bmq/bmqu/bmqu_operationchain_cpp03.cpp

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)