mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 03:33:27 -03:00
qt: Start core thread only when needed
Start the core thread only when needed for initialization or shutdown. Avoids a bit of overhead, and also avoids spamming two log messages before logging is properly initialized.
This commit is contained in:
parent
c715ff52c7
commit
33357b27a0
1 changed files with 11 additions and 5 deletions
|
@ -286,15 +286,17 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
|
||||||
returnValue(0)
|
returnValue(0)
|
||||||
{
|
{
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
startThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitcoinApplication::~BitcoinApplication()
|
BitcoinApplication::~BitcoinApplication()
|
||||||
|
{
|
||||||
|
if(coreThread)
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Stopping thread";
|
qDebug() << __func__ << ": Stopping thread";
|
||||||
emit stopThread();
|
emit stopThread();
|
||||||
coreThread->wait();
|
coreThread->wait();
|
||||||
qDebug() << __func__ << ": Stopped thread";
|
qDebug() << __func__ << ": Stopped thread";
|
||||||
|
}
|
||||||
|
|
||||||
delete window;
|
delete window;
|
||||||
window = 0;
|
window = 0;
|
||||||
|
@ -337,6 +339,8 @@ void BitcoinApplication::createSplashScreen(bool isaTestNet)
|
||||||
|
|
||||||
void BitcoinApplication::startThread()
|
void BitcoinApplication::startThread()
|
||||||
{
|
{
|
||||||
|
if(coreThread)
|
||||||
|
return;
|
||||||
coreThread = new QThread(this);
|
coreThread = new QThread(this);
|
||||||
BitcoinCore *executor = new BitcoinCore();
|
BitcoinCore *executor = new BitcoinCore();
|
||||||
executor->moveToThread(coreThread);
|
executor->moveToThread(coreThread);
|
||||||
|
@ -357,12 +361,14 @@ void BitcoinApplication::startThread()
|
||||||
void BitcoinApplication::requestInitialize()
|
void BitcoinApplication::requestInitialize()
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Requesting initialize";
|
qDebug() << __func__ << ": Requesting initialize";
|
||||||
|
startThread();
|
||||||
emit requestedInitialize();
|
emit requestedInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::requestShutdown()
|
void BitcoinApplication::requestShutdown()
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Requesting shutdown";
|
qDebug() << __func__ << ": Requesting shutdown";
|
||||||
|
startThread();
|
||||||
window->hide();
|
window->hide();
|
||||||
window->setClientModel(0);
|
window->setClientModel(0);
|
||||||
pollShutdownTimer->stop();
|
pollShutdownTimer->stop();
|
||||||
|
|
Loading…
Add table
Reference in a new issue