opt: remove useless code

the mdx**runnable class is useless now ,can be removed.
This commit is contained in:
Xiao YiFang 2022-05-08 16:44:59 +08:00
parent 9c402d986e
commit 9d10ca5c2f

64
mdx.cc
View file

@ -345,7 +345,6 @@ private:
friend class MdxHeadwordsRequest; friend class MdxHeadwordsRequest;
friend class MdxArticleRequest; friend class MdxArticleRequest;
friend class MddResourceRequest; friend class MddResourceRequest;
friend class MdxDeferredInitRunnable;
}; };
MdxRegex MdxDictionary::mdxRx; MdxRegex MdxDictionary::mdxRx;
@ -567,33 +566,8 @@ sptr< Dictionary::DataRequest > MdxDictionary::getSearchResults( QString const &
/// MdxDictionary::getArticle /// MdxDictionary::getArticle
class MdxArticleRequest;
class MdxArticleRequestRunnable: public QRunnable
{
MdxArticleRequest & r;
QSemaphore & hasExited;
public:
MdxArticleRequestRunnable( MdxArticleRequest & r_,
QSemaphore & hasExited_ ):
r( r_ ),
hasExited( hasExited_ )
{}
~MdxArticleRequestRunnable()
{
hasExited.release();
}
virtual void run();
};
class MdxArticleRequest: public Dictionary::DataRequest class MdxArticleRequest: public Dictionary::DataRequest
{ {
friend class MdxArticleRequestRunnable;
wstring word; wstring word;
vector< wstring > alts; vector< wstring > alts;
MdxDictionary & dict; MdxDictionary & dict;
@ -613,7 +587,6 @@ public:
dict( dict_ ), dict( dict_ ),
ignoreDiacritics( ignoreDiacritics_ ) ignoreDiacritics( ignoreDiacritics_ )
{ {
// QThreadPool::globalInstance()->start( new MdxArticleRequestRunnable( *this, hasExited ) );
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } ); QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
} }
@ -631,10 +604,6 @@ public:
} }
}; };
void MdxArticleRequestRunnable::run()
{
r.run();
}
void MdxArticleRequest::run() void MdxArticleRequest::run()
{ {
@ -754,33 +723,8 @@ sptr<Dictionary::DataRequest> MdxDictionary::getArticle( const wstring & word, c
} }
/// MdxDictionary::getResource /// MdxDictionary::getResource
class MddResourceRequest;
class MddResourceRequestRunnable: public QRunnable
{
MddResourceRequest & r;
QSemaphore & hasExited;
public:
MddResourceRequestRunnable( MddResourceRequest & r_,
QSemaphore & hasExited_ ): r( r_ ),
hasExited( hasExited_ )
{}
~MddResourceRequestRunnable()
{
hasExited.release();
}
virtual void run();
};
class MddResourceRequest: public Dictionary::DataRequest class MddResourceRequest: public Dictionary::DataRequest
{ {
friend class MddResourceRequestRunnable;
MdxDictionary & dict; MdxDictionary & dict;
wstring resourceName; wstring resourceName;
QAtomicInt isCancelled; QAtomicInt isCancelled;
@ -793,11 +737,10 @@ public:
dict( dict_ ), dict( dict_ ),
resourceName( Utf8::decode( resourceName_ ) ) resourceName( Utf8::decode( resourceName_ ) )
{ {
//QThreadPool::globalInstance()->start( new MddResourceRequestRunnable( *this, hasExited ) );
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } ); QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
} }
void run(); // Run from another thread by MddResourceRequestRunnable void run();
virtual void cancel() virtual void cancel()
{ {
@ -811,11 +754,6 @@ public:
} }
}; };
void MddResourceRequestRunnable::run()
{
r.run();
}
void MddResourceRequest::run() void MddResourceRequest::run()
{ {
if ( Utils::AtomicInt::loadAcquire( isCancelled ) ) if ( Utils::AtomicInt::loadAcquire( isCancelled ) )