Skip to content

Commit

Permalink
opt: dsl dictionary use lambda function instead of Runnable class
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed May 19, 2022
1 parent 7071bc5 commit e9acba5
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions dsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,29 +345,6 @@ DslDictionary::~DslDictionary()

//////// DslDictionary::deferredInit()

class DslDeferredInitRunnable: public QRunnable
{
DslDictionary & dictionary;
QSemaphore & hasExited;

public:

DslDeferredInitRunnable( DslDictionary & dictionary_,
QSemaphore & hasExited_ ):
dictionary( dictionary_ ), hasExited( hasExited_ )
{}

~DslDeferredInitRunnable()
{
hasExited.release();
}

virtual void run()
{
dictionary.doDeferredInit();
}
};

void DslDictionary::deferredInit()
{
if ( !Utils::AtomicInt::loadAcquire( deferredInitDone ) )
Expand All @@ -379,9 +356,7 @@ void DslDictionary::deferredInit()

if ( !deferredInitRunnableStarted )
{
QThreadPool::globalInstance()->start(
new DslDeferredInitRunnable( *this, deferredInitRunnableExited ),
-1000 );
QThreadPool::globalInstance()->start( [ this ]() { this->doDeferredInit(); }, -1000 );
deferredInitRunnableStarted = true;
}
}
Expand Down

0 comments on commit e9acba5

Please sign in to comment.