Shutdown cleanup prep-work

Create a boost::thread_group object at the qt/bitcoind main-loop level
that will hold pointers to all the main-loop threads.

This will replace the vnThreadsRunning[] array.

For testing, ported the BitcoinMiner threads to use its
own boost::thread_group.
This commit is contained in:
Gavin Andresen
2013-03-06 22:16:05 -05:00
parent 87b9931bed
commit c8c2fbe07f
8 changed files with 63 additions and 82 deletions

View File

@@ -11,6 +11,7 @@
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "util.h"
#include "ui_interface.h"
#include "paymentserver.h"
@@ -215,9 +216,10 @@ int main(int argc, char *argv[])
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
boost::thread_group threadGroup;
BitcoinGUI window;
guiref = &window;
if(AppInit2())
if(AppInit2(threadGroup))
{
{
// Put this in a block, so that the Model objects are cleaned up before
@@ -259,6 +261,8 @@ int main(int argc, char *argv[])
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
Shutdown(NULL);
threadGroup.interrupt_all();
threadGroup.join_all();
}
else
{