1+ // For the purpose of this test we use libuv's threading library. When deciding
2+ // on a threading library for a new project it bears remembering that in the
3+ // future libuv may introduce API changes which may render it non-ABI-stable,
4+ // which, in turn, may affect the ABI stability of the project despite its use
5+ // of N-API.
6+ #include <uv.h>
17#include <node_api.h>
28#include "../../js-native-api/common.h"
39
10+ static uv_thread_t uv_thread ;
11+
12+ static void work_thread (void * data ) {
13+ napi_fatal_error ("work_thread" , NAPI_AUTO_LENGTH ,
14+ "foobar" , NAPI_AUTO_LENGTH );
15+ }
16+
417static napi_value Test (napi_env env , napi_callback_info info ) {
518 napi_fatal_error ("test_fatal::Test" , NAPI_AUTO_LENGTH ,
619 "fatal message" , NAPI_AUTO_LENGTH );
720 return NULL ;
821}
922
23+ static napi_value TestThread (napi_env env , napi_callback_info info ) {
24+ NODE_API_ASSERT (env ,
25+ (uv_thread_create (& uv_thread , work_thread , NULL ) == 0 ),
26+ "Thread creation" );
27+ return NULL ;
28+ }
29+
1030static napi_value TestStringLength (napi_env env , napi_callback_info info ) {
1131 napi_fatal_error ("test_fatal::TestStringLength" , 16 , "fatal message" , 13 );
1232 return NULL ;
@@ -16,6 +36,7 @@ static napi_value Init(napi_env env, napi_value exports) {
1636 napi_property_descriptor properties [] = {
1737 DECLARE_NODE_API_PROPERTY ("Test" , Test ),
1838 DECLARE_NODE_API_PROPERTY ("TestStringLength" , TestStringLength ),
39+ DECLARE_NODE_API_PROPERTY ("TestThread" , TestThread ),
1940 };
2041
2142 NODE_API_CALL (env , napi_define_properties (
0 commit comments