Skip to content

Commit 1129214

Browse files
committed
Solve more issues with node loader, the refactor is working now.
1 parent 37f08e1 commit 1129214

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

source/loaders/node_loader/source/node_loader_impl.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,19 +1572,22 @@ void function_node_interface_destroy(function func, function_impl impl)
15721572
return;
15731573
}
15741574

1575-
loader_impl_node node_impl = node_func->node_impl;
1576-
loader_impl_async_func_destroy_safe_type func_destroy_safe(node_impl, node_func);
1577-
1578-
/* Check if we are in the JavaScript thread */
1579-
if (node_impl->js_thread_id == std::this_thread::get_id())
1580-
{
1581-
/* We are already in the V8 thread, we can call safely */
1582-
node_loader_impl_func_destroy_safe(node_impl->env, &func_destroy_safe);
1583-
}
1584-
else
1575+
if (loader_is_destroyed(node_func->node_impl->impl) != 0)
15851576
{
1586-
/* Submit the task to the async queue */
1587-
loader_impl_threadsafe_invoke_type<loader_impl_async_func_destroy_safe_type> invoke(node_impl->threadsafe_func_destroy, func_destroy_safe);
1577+
loader_impl_node node_impl = node_func->node_impl;
1578+
loader_impl_async_func_destroy_safe_type func_destroy_safe(node_impl, node_func);
1579+
1580+
/* Check if we are in the JavaScript thread */
1581+
if (node_impl->js_thread_id == std::this_thread::get_id())
1582+
{
1583+
/* We are already in the V8 thread, we can call safely */
1584+
node_loader_impl_func_destroy_safe(node_impl->env, &func_destroy_safe);
1585+
}
1586+
else
1587+
{
1588+
/* Submit the task to the async queue */
1589+
loader_impl_threadsafe_invoke_type<loader_impl_async_func_destroy_safe_type> invoke(node_impl->threadsafe_func_destroy, func_destroy_safe);
1590+
}
15881591
}
15891592

15901593
/* Free node function arguments */

source/loaders/ts_loader/source/ts_loader_impl.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,10 @@ static void *ts_loader_impl_destroy_unload_children_cb(size_t size, void *args[]
402402
else
403403
{
404404
loader_impl impl = static_cast<loader_impl>(metacall_value_to_ptr(args[0]));
405-
/* TODO: Should we let Node Loader destroy our handle? */
406-
/*void *ts_impl = static_cast<void *>(loader_impl_get(impl));*/
407405

408406
loader_unload_children(impl);
409407

410-
/* TODO: Should we let Node Loader destroy our handle? */
411-
return metacall_value_create_bool(/*metacall_clear(ts_impl)*/ 1L);
408+
return metacall_value_create_bool(1L);
412409
}
413410
}
414411

0 commit comments

Comments
 (0)