Created
June 13, 2016 08:00
-
-
Save Aschen/e0305cce721439f103f43fff3433c077 to your computer and use it in GitHub Desktop.
ECF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void EpsiFileCompressor::compress(const QString &folder, const QString &ecfFilename) | |
{ | |
QWaitCondition waitCondition; | |
FilePool filepool(folder); | |
ZippedBufferPool zippedBufferPool(&waitCondition); | |
Zipper zipper1(&filepool, &zippedBufferPool); | |
Zipper zipper2(&filepool, &zippedBufferPool); | |
Writter writter(ecfFilename, &zippedBufferPool, &waitCondition); | |
zipper1.start(); | |
zipper2.start(); | |
writter.start(); | |
zipper1.wait(); | |
zipper2.wait(); | |
zippedBufferPool.done(true); | |
writter.wait(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Writter::run() | |
{ | |
m_waitCondition->wait(&m_mutex); | |
ZippedBuffer zippedBuffer = m_zippedBufferPool->tryGet(); | |
while ( ! m_zippedBufferPool->done()) | |
{ | |
if (zippedBuffer.valid()) | |
{ | |
m_stream << zippedBuffer; | |
} | |
zippedBuffer = m_zippedBufferPool->tryGet(); | |
} | |
m_mutex.unlock(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZippedBuffer ZippedBufferPool::tryGet() | |
{ | |
QMutexLocker locker(&m_mutex); | |
ZippedBuffer zippedBuffer; | |
if ( ! m_zippedBuffers.empty()) | |
{ | |
zippedBuffer = m_zippedBuffers.front(); | |
m_zippedBuffers.pop_front(); | |
} | |
return zippedBuffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment