osl::Mutex->std::mutex in FastSaxParserImpl
Change-Id: I3bb067a0aafe8d7ca1171ab7119acbf94323725c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127915 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
bc613dc5db
commit
146ea5360e
@@ -153,7 +153,7 @@ struct Entity : public ParserData
|
|||||||
std::optional<EventList> mxProducedEvents;
|
std::optional<EventList> mxProducedEvents;
|
||||||
std::queue<EventList> maPendingEvents;
|
std::queue<EventList> maPendingEvents;
|
||||||
std::queue<EventList> maUsedEvents;
|
std::queue<EventList> maUsedEvents;
|
||||||
osl::Mutex maEventProtector;
|
std::mutex maEventProtector;
|
||||||
|
|
||||||
static const size_t mnEventLowWater = 4;
|
static const size_t mnEventLowWater = 4;
|
||||||
static const size_t mnEventHighWater = 8;
|
static const size_t mnEventHighWater = 8;
|
||||||
@@ -537,12 +537,12 @@ EventList& Entity::getEventList()
|
|||||||
{
|
{
|
||||||
if (!mxProducedEvents)
|
if (!mxProducedEvents)
|
||||||
{
|
{
|
||||||
osl::ClearableMutexGuard aGuard(maEventProtector);
|
std::unique_lock aGuard(maEventProtector);
|
||||||
if (!maUsedEvents.empty())
|
if (!maUsedEvents.empty())
|
||||||
{
|
{
|
||||||
mxProducedEvents = std::move(maUsedEvents.front());
|
mxProducedEvents = std::move(maUsedEvents.front());
|
||||||
maUsedEvents.pop();
|
maUsedEvents.pop();
|
||||||
aGuard.clear(); // unlock
|
aGuard.unlock(); // unlock
|
||||||
mnProducedEventsSize = 0;
|
mnProducedEventsSize = 0;
|
||||||
}
|
}
|
||||||
if (!mxProducedEvents)
|
if (!mxProducedEvents)
|
||||||
@@ -856,7 +856,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
|
|||||||
rEntity.maConsumeResume.wait();
|
rEntity.maConsumeResume.wait();
|
||||||
rEntity.maConsumeResume.reset();
|
rEntity.maConsumeResume.reset();
|
||||||
|
|
||||||
osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
|
std::unique_lock aGuard(rEntity.maEventProtector);
|
||||||
while (!rEntity.maPendingEvents.empty())
|
while (!rEntity.maPendingEvents.empty())
|
||||||
{
|
{
|
||||||
if (rEntity.maPendingEvents.size() <= Entity::mnEventLowWater)
|
if (rEntity.maPendingEvents.size() <= Entity::mnEventLowWater)
|
||||||
@@ -864,16 +864,16 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
|
|||||||
|
|
||||||
EventList aEventList = std::move(rEntity.maPendingEvents.front());
|
EventList aEventList = std::move(rEntity.maPendingEvents.front());
|
||||||
rEntity.maPendingEvents.pop();
|
rEntity.maPendingEvents.pop();
|
||||||
aGuard.clear(); // unlock
|
aGuard.unlock(); // unlock
|
||||||
|
|
||||||
if (!consume(aEventList))
|
if (!consume(aEventList))
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
aGuard.reset(); // lock
|
aGuard.lock(); // lock
|
||||||
|
|
||||||
if ( rEntity.maPendingEvents.size() <= Entity::mnEventLowWater )
|
if ( rEntity.maPendingEvents.size() <= Entity::mnEventLowWater )
|
||||||
{
|
{
|
||||||
aGuard.clear();
|
aGuard.unlock();
|
||||||
for (auto& rEvent : aEventList.maEvents)
|
for (auto& rEvent : aEventList.maEvents)
|
||||||
{
|
{
|
||||||
if (rEvent.mxAttributes.is())
|
if (rEvent.mxAttributes.is())
|
||||||
@@ -884,7 +884,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
|
|||||||
}
|
}
|
||||||
aEventList.mbIsAttributesEmpty = true;
|
aEventList.mbIsAttributesEmpty = true;
|
||||||
}
|
}
|
||||||
aGuard.reset();
|
aGuard.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
rEntity.maUsedEvents.push(std::move(aEventList));
|
rEntity.maUsedEvents.push(std::move(aEventList));
|
||||||
@@ -973,7 +973,7 @@ void FastSaxParserImpl::setCustomEntityNames(
|
|||||||
void FastSaxParserImpl::deleteUsedEvents()
|
void FastSaxParserImpl::deleteUsedEvents()
|
||||||
{
|
{
|
||||||
Entity& rEntity = getEntity();
|
Entity& rEntity = getEntity();
|
||||||
osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
|
std::unique_lock aGuard(rEntity.maEventProtector);
|
||||||
|
|
||||||
while (!rEntity.maUsedEvents.empty())
|
while (!rEntity.maUsedEvents.empty())
|
||||||
{
|
{
|
||||||
@@ -981,10 +981,10 @@ void FastSaxParserImpl::deleteUsedEvents()
|
|||||||
EventList aEventList = std::move(rEntity.maUsedEvents.front());
|
EventList aEventList = std::move(rEntity.maUsedEvents.front());
|
||||||
rEntity.maUsedEvents.pop();
|
rEntity.maUsedEvents.pop();
|
||||||
|
|
||||||
aGuard.clear(); // unlock
|
aGuard.unlock(); // unlock
|
||||||
}
|
}
|
||||||
|
|
||||||
aGuard.reset(); // lock
|
aGuard.lock(); // lock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -995,21 +995,21 @@ void FastSaxParserImpl::produce( bool bForceFlush )
|
|||||||
rEntity.mnProducedEventsSize >= Entity::mnEventListSize))
|
rEntity.mnProducedEventsSize >= Entity::mnEventListSize))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
|
std::unique_lock aGuard(rEntity.maEventProtector);
|
||||||
|
|
||||||
while (rEntity.maPendingEvents.size() >= Entity::mnEventHighWater)
|
while (rEntity.maPendingEvents.size() >= Entity::mnEventHighWater)
|
||||||
{ // pause parsing for a bit
|
{ // pause parsing for a bit
|
||||||
aGuard.clear(); // unlock
|
aGuard.unlock(); // unlock
|
||||||
rEntity.maProduceResume.wait();
|
rEntity.maProduceResume.wait();
|
||||||
rEntity.maProduceResume.reset();
|
rEntity.maProduceResume.reset();
|
||||||
aGuard.reset(); // lock
|
aGuard.lock(); // lock
|
||||||
}
|
}
|
||||||
|
|
||||||
rEntity.maPendingEvents.push(std::move(*rEntity.mxProducedEvents));
|
rEntity.maPendingEvents.push(std::move(*rEntity.mxProducedEvents));
|
||||||
rEntity.mxProducedEvents.reset();
|
rEntity.mxProducedEvents.reset();
|
||||||
assert(!rEntity.mxProducedEvents);
|
assert(!rEntity.mxProducedEvents);
|
||||||
|
|
||||||
aGuard.clear(); // unlock
|
aGuard.unlock(); // unlock
|
||||||
|
|
||||||
rEntity.maConsumeResume.set();
|
rEntity.maConsumeResume.set();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user