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; 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;
} }