File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 8
8
#include " init.h"
9
9
#include " main.h"
10
10
#include " noui.h"
11
+ #include " scheduler.h"
11
12
#include " util.h"
12
13
13
14
#include < boost/algorithm/string/predicate.hpp>
@@ -55,6 +56,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
55
56
bool AppInit (int argc, char * argv[])
56
57
{
57
58
boost::thread_group threadGroup;
59
+ CScheduler scheduler;
58
60
59
61
bool fRet = false ;
60
62
@@ -142,7 +144,7 @@ bool AppInit(int argc, char* argv[])
142
144
#endif
143
145
SoftSetBoolArg (" -server" , true );
144
146
145
- fRet = AppInit2 (threadGroup);
147
+ fRet = AppInit2 (threadGroup, scheduler );
146
148
}
147
149
catch (const std::exception& e) {
148
150
PrintExceptionContinue (&e, " AppInit()" );
Original file line number Diff line number Diff line change 19
19
#include " net.h"
20
20
#include " rpcserver.h"
21
21
#include " script/standard.h"
22
+ #include " scheduler.h"
22
23
#include " txdb.h"
23
24
#include " ui_interface.h"
24
25
#include " util.h"
@@ -564,7 +565,7 @@ bool InitSanityCheck(void)
564
565
/* * Initialize bitcoin.
565
566
* @pre Parameters should be parsed and config file should be read.
566
567
*/
567
- bool AppInit2 (boost::thread_group& threadGroup)
568
+ bool AppInit2 (boost::thread_group& threadGroup, CScheduler& scheduler )
568
569
{
569
570
// ********************************************************* Step 1: setup
570
571
#ifdef _MSC_VER
@@ -890,6 +891,10 @@ bool AppInit2(boost::thread_group& threadGroup)
890
891
threadGroup.create_thread (&ThreadScriptCheck);
891
892
}
892
893
894
+ // Start the lightweight task scheduler thread
895
+ CScheduler::Function serviceLoop = boost::bind (&CScheduler::serviceQueue, &scheduler);
896
+ threadGroup.create_thread (boost::bind (&TraceThread<CScheduler::Function>, " scheduler" , serviceLoop));
897
+
893
898
/* Start the RPC server already. It will be started in "warmup" mode
894
899
* and not really process calls already (but it will signify connections
895
900
* that the server is there and will be ready later). Warmup mode will
Original file line number Diff line number Diff line change 8
8
9
9
#include < string>
10
10
11
+ class CScheduler ;
11
12
class CWallet ;
12
13
13
14
namespace boost
@@ -20,7 +21,7 @@ extern CWallet* pwalletMain;
20
21
void StartShutdown ();
21
22
bool ShutdownRequested ();
22
23
void Shutdown ();
23
- bool AppInit2 (boost::thread_group& threadGroup);
24
+ bool AppInit2 (boost::thread_group& threadGroup, CScheduler& scheduler );
24
25
25
26
/* * The help message mode determines what help message to show */
26
27
enum HelpMessageMode {
Original file line number Diff line number Diff line change 26
26
#include " init.h"
27
27
#include " main.h"
28
28
#include " rpcserver.h"
29
+ #include " scheduler.h"
29
30
#include " ui_interface.h"
30
31
#include " util.h"
31
32
@@ -178,6 +179,7 @@ public slots:
178
179
179
180
private:
180
181
boost::thread_group threadGroup;
182
+ CScheduler scheduler;
181
183
182
184
// / Pass fatal exception message to UI thread
183
185
void handleRunawayException (const std::exception *e);
@@ -258,7 +260,7 @@ void BitcoinCore::initialize()
258
260
try
259
261
{
260
262
qDebug () << __func__ << " : Running AppInit2 in thread" ;
261
- int rv = AppInit2 (threadGroup);
263
+ int rv = AppInit2 (threadGroup, scheduler );
262
264
if (rv)
263
265
{
264
266
/* Start a dummy RPC thread if no RPC thread is active yet
You can’t perform that action at this time.
0 commit comments