Skip to content
Permalink
Browse files

core, fest: support custom platform.

  • Loading branch information...
xicilion committed Sep 9, 2018
1 parent dfa60c8 commit 246e9687aed95332ed003b0393c7c690c7f46031
Showing with 21 additions and 10 deletions.
  1. +2 −0 fibjs/include/fibjs.h
  2. +3 −0 fibjs/program/src/fibjs.cpp
  3. +16 −10 fibjs/src/base/Runtime.cpp
@@ -12,6 +12,8 @@

namespace fibjs {

void init_coroutine();
void init_platform(v8::Platform* platform = NULL);
void run_gui();
void start(int32_t argc, char** argv, result_t (*main)(Isolate*));
result_t main_fiber(Isolate* isolate);
@@ -68,6 +68,9 @@ void main(int32_t argc, char** argv)
{
importModule();

init_coroutine();
init_platform();

start(argc, argv, main_fiber);
run_gui();
}
@@ -24,6 +24,7 @@
#include "v8_api.h"
#include "options.h"
#include "include/libplatform/libplatform.h"
#include "fibjs.h"

namespace fibjs {

@@ -40,19 +41,29 @@ result_t ifZipFile(exlib::string filename, bool& retVal);

exlib::string s_root;

static void init()
void init_coroutine()
{
::setlocale(LC_ALL, "");

int32_t cpus = 0;

process_base::cwd(s_root);

os_base::cpuNumbers(cpus);
if (cpus < 2)
cpus = 2;

exlib::Service::init(cpus + 1);
}

void init_platform(v8::Platform* platform)
{
if (platform == NULL)
platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
}

static void init()
{
process_base::cwd(s_root);
::setlocale(LC_ALL, "");

init_date();
init_acThread();
@@ -64,11 +75,6 @@ static void init()
#endif

srand((unsigned int)time(0));

v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);

v8::V8::Initialize();
}

void start(int32_t argc, char** argv, result_t (*main)(Isolate*))

0 comments on commit 246e968

Please sign in to comment.
You can’t perform that action at this time.