Moved some logic to C++, which will extract i2p if it's not already,

and then secondly fire up the router in a second java process when 
extraction is completed. Gonna use "optional" type in C++ to make
global variables a bit less painful to use.
This commit is contained in:
meeh
2018-07-08 13:16:07 +00:00
parent 27a0d4e51e
commit 21b3864dfd
8 changed files with 165 additions and 49 deletions

View File

@ -2,8 +2,10 @@
#include <dispatch/dispatch.h>
#include <subprocess.hpp>
#include <future>
using namespace subprocess;
using namespace std::experimental;
JavaRunner::JavaRunner(std::string javaBin, const fp_proc_t& execFn, const fp_t& cb)
: javaBinaryPath(javaBin), executingFn(execFn), exitCallbackFn(cb)
@ -11,7 +13,7 @@ JavaRunner::JavaRunner(std::string javaBin, const fp_proc_t& execFn, const fp_t&
javaProcess = std::shared_ptr<Popen>(new Popen({javaBin.c_str(), "-version"}, defer_spawn{true}));
}
void JavaRunner::execute()
optional<std::future<int> > JavaRunner::execute()
{
try {
auto executingFn = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS, ^{
@ -24,7 +26,9 @@ void JavaRunner::execute()
printf("Finished executingFn - Runs callbackFn\n");
this->exitCallbackFn();
return std::async(std::launch::async, []{ return 0; });
} catch (std::exception* ex) {
printf("ERROR: %s\n", ex->what());
return nullopt;
}
}