Skip to content

Improvement: stop MQTP queues in parallel #1028

@678098

Description

@678098

bmqc::MultiQueueThreadPool::stop iterates over all processing queues and enqueues a monitor event to request stop, then wait each queue to stop serially.
It might be more efficient to split this loop in two loops.
In the first loop, send a monitor event to the queue and disable push.
In the second loop, wait for all queues to finish using the shared TimedSemaphore.

Implementing this causes some tests to fail. We might have hidden assumptions how the stop is done, and it's worth investigating.

The code:

for (size_t i = 0; i < d_queues.size(); ++i) {
QueueInfo& info = d_queues[i];
QueueItem item = {false // isMonitorEvent
,
0}; // pointer to event
info.d_queue_p->pushBack(item);
info.d_queue_p->disablePushBack();
// TODO: Change 'd_processedZero' to semaphore instead to avoid busy
// waiting?
while (!info.d_processedZero) {
bslmt::ThreadUtil::yield();
}
while (!info.d_queue_p->tryPopFront(&item)) {
d_pool.releaseObject(item.d_event_p);
}
d_allocator_p->deleteObject(info.d_queue_p);
info.reset();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions