clean code:remove mdx runnable

This commit is contained in:
xiaoyifang 2022-04-18 22:23:48 +08:00
parent c34bde252e
commit fc0b33181c

31
mdx.cc
View file

@ -252,7 +252,6 @@ class MdxDictionary: public BtreeIndexing::BtreeDictionary
QAtomicInt deferredInitDone;
Mutex deferredInitMutex;
bool deferredInitRunnableStarted;
QSemaphore deferredInitRunnableExited;
string initError;
QString cacheDirName;
@ -400,10 +399,6 @@ MdxDictionary::~MdxDictionary()
{
Mutex::Lock _( deferredInitMutex );
// Wait for init runnable to complete if it was ever started
// if ( deferredInitRunnableStarted )
// deferredInitRunnableExited.acquire();
dictFile.close();
removeDirectory( cacheDirName );
@ -411,29 +406,6 @@ MdxDictionary::~MdxDictionary()
//////// 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()
{
if ( !Utils::AtomicInt::loadAcquire( deferredInitDone ) )
@ -445,9 +417,6 @@ void MdxDictionary::deferredInit()
if ( !deferredInitRunnableStarted )
{
// QThreadPool::globalInstance()->start(
// new MdxDeferredInitRunnable( *this, deferredInitRunnableExited ),
// -1000 );
QThreadPool::globalInstance()->start( [ this ]() { this->doDeferredInit(); },-1000 );
deferredInitRunnableStarted = true;
}