mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
Create a scheduler thread for lightweight tasks
This commit is contained in:
parent
68d370bec4
commit
ddd0acd3db
@ -8,6 +8,7 @@
|
|||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "noui.h"
|
#include "noui.h"
|
||||||
|
#include "scheduler.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
@ -55,6 +56,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
|||||||
bool AppInit(int argc, char* argv[])
|
bool AppInit(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
CScheduler scheduler;
|
||||||
|
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
|
|
||||||
@ -142,7 +144,7 @@ bool AppInit(int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
SoftSetBoolArg("-server", true);
|
SoftSetBoolArg("-server", true);
|
||||||
|
|
||||||
fRet = AppInit2(threadGroup);
|
fRet = AppInit2(threadGroup, scheduler);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
PrintExceptionContinue(&e, "AppInit()");
|
PrintExceptionContinue(&e, "AppInit()");
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "rpcserver.h"
|
#include "rpcserver.h"
|
||||||
#include "script/standard.h"
|
#include "script/standard.h"
|
||||||
|
#include "scheduler.h"
|
||||||
#include "txdb.h"
|
#include "txdb.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -564,7 +565,7 @@ bool InitSanityCheck(void)
|
|||||||
/** Initialize bitcoin.
|
/** Initialize bitcoin.
|
||||||
* @pre Parameters should be parsed and config file should be read.
|
* @pre Parameters should be parsed and config file should be read.
|
||||||
*/
|
*/
|
||||||
bool AppInit2(boost::thread_group& threadGroup)
|
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
{
|
{
|
||||||
// ********************************************************* Step 1: setup
|
// ********************************************************* Step 1: setup
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -890,6 +891,10 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||||||
threadGroup.create_thread(&ThreadScriptCheck);
|
threadGroup.create_thread(&ThreadScriptCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start the lightweight task scheduler thread
|
||||||
|
CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler);
|
||||||
|
threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>, "scheduler", serviceLoop));
|
||||||
|
|
||||||
/* Start the RPC server already. It will be started in "warmup" mode
|
/* Start the RPC server already. It will be started in "warmup" mode
|
||||||
* and not really process calls already (but it will signify connections
|
* and not really process calls already (but it will signify connections
|
||||||
* that the server is there and will be ready later). Warmup mode will
|
* that the server is there and will be ready later). Warmup mode will
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class CScheduler;
|
||||||
class CWallet;
|
class CWallet;
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@ -20,7 +21,7 @@ extern CWallet* pwalletMain;
|
|||||||
void StartShutdown();
|
void StartShutdown();
|
||||||
bool ShutdownRequested();
|
bool ShutdownRequested();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
bool AppInit2(boost::thread_group& threadGroup);
|
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler);
|
||||||
|
|
||||||
/** The help message mode determines what help message to show */
|
/** The help message mode determines what help message to show */
|
||||||
enum HelpMessageMode {
|
enum HelpMessageMode {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "rpcserver.h"
|
#include "rpcserver.h"
|
||||||
|
#include "scheduler.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -178,6 +179,7 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
CScheduler scheduler;
|
||||||
|
|
||||||
/// Pass fatal exception message to UI thread
|
/// Pass fatal exception message to UI thread
|
||||||
void handleRunawayException(const std::exception *e);
|
void handleRunawayException(const std::exception *e);
|
||||||
@ -258,7 +260,7 @@ void BitcoinCore::initialize()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Running AppInit2 in thread";
|
qDebug() << __func__ << ": Running AppInit2 in thread";
|
||||||
int rv = AppInit2(threadGroup);
|
int rv = AppInit2(threadGroup, scheduler);
|
||||||
if(rv)
|
if(rv)
|
||||||
{
|
{
|
||||||
/* Start a dummy RPC thread if no RPC thread is active yet
|
/* Start a dummy RPC thread if no RPC thread is active yet
|
||||||
|
Loading…
Reference in New Issue
Block a user