Skip to content

Commit

Permalink
Add doc and improve a bit the test related to advanced async destroy …
Browse files Browse the repository at this point in the history
…in node loader & clang-format.
  • Loading branch information
viferga committed Mar 26, 2021
1 parent 4b61c2f commit cfa0a68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/loaders/node_loader/source/node_loader_trampoline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ napi_value node_loader_trampoline_destroy(napi_env env, napi_callback_info info)
/* Get the node impl pointer */
loader_impl_node node_impl;

status = napi_get_value_external(env, args[0], (void**)&node_impl);
status = napi_get_value_external(env, args[0], (void **)&node_impl);

node_loader_impl_exception(env, status);

Expand Down Expand Up @@ -324,7 +324,7 @@ napi_value node_loader_trampoline_requested_destroy(napi_env env, napi_callback_
/* Get the node impl pointer */
loader_impl_node node_impl;

status = napi_get_value_external(env, args[0], (void**)&node_impl);
status = napi_get_value_external(env, args[0], (void **)&node_impl);

node_loader_impl_exception(env, status);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ TEST_F(metacall_node_python_async_after_destroy_test, DefaultConstructor)
"def sum(a, b):\n"
" return a + b\n"
"`);\n"
"setTimeout(() => { metacall('sum', 3, 4) === 7 || process.exit(1) }, 1000);\n"
"setTimeout(() => { metacall('sum', 3, 4) === 7 || process.exit(1) }, 2000);\n"
"setTimeout(() => { metacall('sum', 3, 4) === 7 || process.exit(1) }, 3000);\n";
"function log(x) { console.log(x); return x; }\n"
"setTimeout(() => { log(metacall('sum', 3, 4)) === 7 || process.exit(1) }, 2000);\n"
"setTimeout(() => { log(metacall('sum', 3, 4)) === 7 || process.exit(1) }, 4000);\n"
"setTimeout(() => { log(metacall('sum', 3, 4)) === 7 || process.exit(1) }, 6000);\n";

ASSERT_EQ((int)0, (int)metacall_load_from_memory("node", buffer, sizeof(buffer), NULL));
}
Expand All @@ -59,6 +60,9 @@ TEST_F(metacall_node_python_async_after_destroy_test, DefaultConstructor)
/* This should be called before the setTimeout ends, so we can test if the node loader waits
* to be destroyed until the event loop is completely cleaned, so we can call safely to python
* even if the destroy was already emmited, for more info:
* https://github.com/metacall/core/commit/4b61c2f3b22065472828dc7b718defbfc4ac3884
* https://github.com/metacall/core/commit/e963515cf68e04c91ba0612227d5ef586c08aab6
* https://github.com/metacall/core/commit/df701d779af0d2a7cb1f27e33aacf5f17ae20f4b
* https://github.com/metacall/core/commit/1fc9c9244d7a5553861a458813d2cf1488ebe08c
* https://github.com/metacall/core/commit/9b64ee533079fa0d543fc346fb7149d1086451f0
* https://github.com/metacall/core/commit/22bd999c281f23aac04cea7df435a836631706da
Expand Down

0 comments on commit cfa0a68

Please sign in to comment.