mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
clean code:remove mdx runnable
This commit is contained in:
parent
c34bde252e
commit
fc0b33181c
31
mdx.cc
31
mdx.cc
|
@ -252,7 +252,6 @@ class MdxDictionary: public BtreeIndexing::BtreeDictionary
|
||||||
QAtomicInt deferredInitDone;
|
QAtomicInt deferredInitDone;
|
||||||
Mutex deferredInitMutex;
|
Mutex deferredInitMutex;
|
||||||
bool deferredInitRunnableStarted;
|
bool deferredInitRunnableStarted;
|
||||||
QSemaphore deferredInitRunnableExited;
|
|
||||||
|
|
||||||
string initError;
|
string initError;
|
||||||
QString cacheDirName;
|
QString cacheDirName;
|
||||||
|
@ -400,10 +399,6 @@ MdxDictionary::~MdxDictionary()
|
||||||
{
|
{
|
||||||
Mutex::Lock _( deferredInitMutex );
|
Mutex::Lock _( deferredInitMutex );
|
||||||
|
|
||||||
// Wait for init runnable to complete if it was ever started
|
|
||||||
// if ( deferredInitRunnableStarted )
|
|
||||||
// deferredInitRunnableExited.acquire();
|
|
||||||
|
|
||||||
dictFile.close();
|
dictFile.close();
|
||||||
|
|
||||||
removeDirectory( cacheDirName );
|
removeDirectory( cacheDirName );
|
||||||
|
@ -411,29 +406,6 @@ MdxDictionary::~MdxDictionary()
|
||||||
|
|
||||||
//////// MdxDictionary::deferredInit()
|
//////// MdxDictionary::deferredInit()
|
||||||
|
|
||||||
class MdxDeferredInitRunnable: public QRunnable
|
|
||||||
{
|
|
||||||
MdxDictionary & dictionary;
|
|
||||||
QSemaphore & hasExited;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
MdxDeferredInitRunnable( MdxDictionary & dictionary_,
|
|
||||||
QSemaphore & hasExited_ ):
|
|
||||||
dictionary( dictionary_ ), hasExited( hasExited_ )
|
|
||||||
{}
|
|
||||||
|
|
||||||
~MdxDeferredInitRunnable()
|
|
||||||
{
|
|
||||||
hasExited.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void run()
|
|
||||||
{
|
|
||||||
dictionary.doDeferredInit();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void MdxDictionary::deferredInit()
|
void MdxDictionary::deferredInit()
|
||||||
{
|
{
|
||||||
if ( !Utils::AtomicInt::loadAcquire( deferredInitDone ) )
|
if ( !Utils::AtomicInt::loadAcquire( deferredInitDone ) )
|
||||||
|
@ -445,9 +417,6 @@ void MdxDictionary::deferredInit()
|
||||||
|
|
||||||
if ( !deferredInitRunnableStarted )
|
if ( !deferredInitRunnableStarted )
|
||||||
{
|
{
|
||||||
// QThreadPool::globalInstance()->start(
|
|
||||||
// new MdxDeferredInitRunnable( *this, deferredInitRunnableExited ),
|
|
||||||
// -1000 );
|
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->doDeferredInit(); },-1000 );
|
QThreadPool::globalInstance()->start( [ this ]() { this->doDeferredInit(); },-1000 );
|
||||||
deferredInitRunnableStarted = true;
|
deferredInitRunnableStarted = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue