summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/datastream.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-27 21:57:25 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-30 12:33:27 -0500
commit2c795105213a28eb5188374a672eb128191df07d (patch)
tree4a3c5e1c0a564db495dd5f797f2c3e8c7e3f6f25 /sc/source/ui/docshell/datastream.cxx
parentbce780ded4459ed3b20fceda7fd8f1b0523b5227 (diff)
Misc cleanup.
Change-Id: Ia3d0f2e098804dabdbdd324562097b9f69528d35
Diffstat (limited to 'sc/source/ui/docshell/datastream.cxx')
-rw-r--r--sc/source/ui/docshell/datastream.cxx33
1 files changed, 20 insertions, 13 deletions
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 4e7e1ee31a95..d71233b42376 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -96,6 +96,15 @@ private:
}
};
+void emptyLineQueue( std::queue<LinesList*>& rQueue )
+{
+ while (!rQueue.empty())
+ {
+ delete rQueue.front();
+ rQueue.pop();
+ }
+}
+
class ReaderThread : public salhelper::Thread
{
SvStream *mpStream;
@@ -117,23 +126,14 @@ public:
virtual ~ReaderThread()
{
delete mpStream;
- while (!maPendingLines.empty())
- {
- delete maPendingLines.front();
- maPendingLines.pop();
- }
- while (!maUsedLines.empty())
- {
- delete maUsedLines.front();
- maUsedLines.pop();
- }
+ emptyLineQueue(maPendingLines);
+ emptyLineQueue(maUsedLines);
}
void endThread()
{
mbTerminateReading = true;
maProduceResume.set();
- join();
}
private:
@@ -141,8 +141,9 @@ private:
{
while (!mbTerminateReading)
{
- LinesList *pLines = 0;
+ LinesList* pLines = NULL;
osl::ResettableMutexGuard aGuard(maLinesProtector);
+
if (!maUsedLines.empty())
{
pLines = maUsedLines.front();
@@ -154,11 +155,14 @@ private:
aGuard.clear(); // unlock
pLines = new LinesList(10);
}
+
for (size_t i = 0; i < pLines->size(); ++i)
mpStream->ReadLine( pLines->at(i) );
+
aGuard.reset(); // lock
while (!mbTerminateReading && maPendingLines.size() >= 8)
- { // pause reading for a bit
+ {
+ // pause reading for a bit
aGuard.clear(); // unlock
maProduceResume.wait();
maProduceResume.reset();
@@ -251,7 +255,10 @@ DataStream::~DataStream()
mxThread->maStart.set();
mxThread->join();
if (mxReaderThread.is())
+ {
mxReaderThread->endThread();
+ mxReaderThread->join();
+ }
delete mpLines;
}