@@ -9,10 +9,10 @@ void install(jsi::Runtime& runtime) {
9
9
ThreadPool pool (MAX_THREAD_COUNT);
10
10
// TODO: Create runtimes for each thread pool? can I do on-demand instead?
11
11
12
- // spawnThread(() => Promise<void>)
12
+ // spawnThread(run: () => Promise<void>)
13
13
auto spawnThread = jsi::Function::createFromHostFunction (runtime,
14
14
jsi::PropNameID::forAscii (runtime, " spawnThread" ),
15
- 1 , // func
15
+ 1 , // run
16
16
[&pool](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value {
17
17
auto function = arguments[0 ].asObject (runtime).asFunction (runtime);
18
18
auto spawnThreadCallback = jsi::Function::createFromHostFunction (runtime,
@@ -23,13 +23,13 @@ void install(jsi::Runtime& runtime) {
23
23
arguments[0 ]
24
24
.asObject (runtime)
25
25
.asFunction (runtime)
26
- .call (runtime, jsi::Array::createWithElements (runtime, value), 1 );
26
+ .call (runtime, value);
27
27
};
28
28
auto rejecter = [&runtime, &arguments](std::string message) {
29
29
arguments[1 ]
30
30
.asObject (runtime)
31
31
.asFunction (runtime)
32
- .call (runtime, jsi::Array::createWithElements (runtime, jsi:: JSError (runtime, message)), 1 );
32
+ .call (runtime, jsi::JSError (runtime, message). value () );
33
33
};
34
34
// TODO: Adapt Function -> Shared Value
35
35
pool.enqueue ([&resolver, &rejecter]() {
@@ -48,7 +48,7 @@ void install(jsi::Runtime& runtime) {
48
48
auto promise = newPromise
49
49
.asObject (runtime)
50
50
.asFunction (runtime)
51
- .call (runtime, jsi::Array::createWithElements (runtime, spawnThreadCallback), 1 );
51
+ .call (runtime, spawnThreadCallback);
52
52
53
53
return promise;
54
54
});
0 commit comments