text
stringlengths 0
2.2M
|
---|
#define LOOP_ASSERT BSLIM_TESTUTIL_LOOP_ASSERT
|
#define LOOP0_ASSERT BSLIM_TESTUTIL_LOOP0_ASSERT
|
#define LOOP1_ASSERT BSLIM_TESTUTIL_LOOP1_ASSERT
|
#define LOOP2_ASSERT BSLIM_TESTUTIL_LOOP2_ASSERT
|
#define LOOP3_ASSERT BSLIM_TESTUTIL_LOOP3_ASSERT
|
#define LOOP4_ASSERT BSLIM_TESTUTIL_LOOP4_ASSERT
|
#define LOOP5_ASSERT BSLIM_TESTUTIL_LOOP5_ASSERT
|
#define LOOP6_ASSERT BSLIM_TESTUTIL_LOOP6_ASSERT
|
#define Q BSLIM_TESTUTIL_Q // Quote identifier literally.
|
#define P BSLIM_TESTUTIL_P // Print identifier and value.
|
#define P_ BSLIM_TESTUTIL_P_ // P(X) without '\n'.
|
#define T_ BSLIM_TESTUTIL_T_ // Print a tab (w/o newline).
|
#define L_ BSLIM_TESTUTIL_L_ // current Line number
|
// ============================================================================
|
// GLOBAL TYPES, CONSTANTS, AND VARIABLES FOR TESTING
|
// ----------------------------------------------------------------------------
|
static int verbose = 0;
|
static int veryVerbose = 0;
|
static int veryVeryVerbose = 0;
|
static int veryVeryVeryVerbose = 0;
|
// ============================================================================
|
// GLOBAL SUPPORT FUNCTIONS AND CLASSES FOR TESTING
|
// ----------------------------------------------------------------------------
|
// ===============
|
// class TestQueue
|
// ===============
|
class TestQueue {
|
// This class appears in the usage example for the ThreadMultiplexor
|
// component. It associates a multiplexor with a thread pool, so that
|
// threads in the thread pool execute all their jobs through the
|
// multiplexor.
|
// DATA
|
bdlmt::FixedThreadPool *d_threadPool_p; // (held, not owned)
|
bdlmt::ThreadMultiplexor d_multiplexor; // used to partition threads
|
// NOT IMPLEMENTED
|
TestQueue(const TestQueue&);
|
TestQueue& operator=(const TestQueue&);
|
public:
|
// TYPES
|
typedef bdlmt::ThreadMultiplexor::Job Job;
|
// CREATORS
|
TestQueue(int maxProcessors,
|
int queueCapacity,
|
bdlmt::FixedThreadPool *threadPool,
|
bslma::Allocator *basicAllocator = 0);
|
~TestQueue();
|
// MANIPULATORS
|
int processJob(const Job& job);
|
// Submit the specified 'job' to the thread pool. If there are
|
// processors available according to the multiplexor, the job will be
|
// executed immediately; otherwise it will be enqueued.
|
bdlmt::ThreadMultiplexor *multiplexor();
|
// Return a pointer to the modifiable "multiplexor" attribute.
|
};
|
// CREATORS
|
TestQueue::TestQueue(int maxProcessors,
|
int queueCapacity,
|
bdlmt::FixedThreadPool *threadPool,
|
bslma::Allocator *basicAllocator)
|
: d_threadPool_p(threadPool)
|
, d_multiplexor(maxProcessors, queueCapacity, basicAllocator)
|
{
|
}
|
TestQueue::~TestQueue()
|
{
|
}
|
// MANIPULATORS
|
int TestQueue::processJob(const TestQueue::Job& job)
|
{
|
return d_threadPool_p->tryEnqueueJob(bdlf::BindUtil::bind(
|
&bdlmt::ThreadMultiplexor::processJob<Job>,
|
&d_multiplexor,
|
job));
|
}
|
bdlmt::ThreadMultiplexor *TestQueue::multiplexor() {
|
return &d_multiplexor;
|
}
|
// ======================
|
// class UsageTestChecker
|
// ======================
|
class UsageTestChecker {
|