n-api: mark thread-safe function as stable · nodejs/node@d6ffabc · GitHub
Skip to content

Commit d6ffabc

Browse files
Gabriel SchulhofBethGriggs
authored andcommitted
n-api: mark thread-safe function as stable
Fixes: #24249 PR-URL: #25556 Backport-PR-URL: #25648 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 44609d1 commit d6ffabc

6 files changed

Lines changed: 29 additions & 29 deletions

File tree

doc/api/n-api.md

Lines changed: 11 additions & 11 deletions

src/node_api.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33

44
#include <stddef.h>
55
#include <stdbool.h>
6-
#include "node_api_types.h"
7-
8-
struct uv_loop_s; // Forward declaration.
96

107
#ifndef NAPI_VERSION
118
#ifdef NAPI_EXPERIMENTAL
129
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
1310
#define NAPI_VERSION 2147483647
1411
#else
1512
// The baseline version for N-API
16-
#define NAPI_VERSION 3
13+
#define NAPI_VERSION 4
1714
#endif
1815
#endif
1916

17+
#include "node_api_types.h"
18+
19+
struct uv_loop_s; // Forward declaration.
20+
2021
#ifdef _WIN32
2122
#ifdef BUILDING_NODE_EXTENSION
2223
#ifdef EXTERNAL_NAPI
@@ -614,7 +615,7 @@ NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env,
614615

615616
#endif // NAPI_VERSION >= 3
616617

617-
#ifdef NAPI_EXPERIMENTAL
618+
#if NAPI_VERSION >= 4
618619

619620
// Calling into JS from other threads
620621
NAPI_EXTERN napi_status
@@ -652,7 +653,7 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
652653
NAPI_EXTERN napi_status
653654
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
654655

655-
#endif // NAPI_EXPERIMENTAL
656+
#endif // NAPI_VERSION >= 4
656657

657658
EXTERN_C_END
658659

src/node_api_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ typedef struct napi_callback_info__ *napi_callback_info;
2020
typedef struct napi_async_context__ *napi_async_context;
2121
typedef struct napi_async_work__ *napi_async_work;
2222
typedef struct napi_deferred__ *napi_deferred;
23-
#ifdef NAPI_EXPERIMENTAL
23+
#if NAPI_VERSION >= 4
2424
typedef struct napi_threadsafe_function__* napi_threadsafe_function;
25-
#endif // NAPI_EXPERIMENTAL
25+
#endif // NAPI_VERSION >= 4
2626

2727
typedef enum {
2828
napi_default = 0,
@@ -76,13 +76,13 @@ typedef enum {
7676
napi_escape_called_twice,
7777
napi_handle_scope_mismatch,
7878
napi_callback_scope_mismatch,
79-
#ifdef NAPI_EXPERIMENTAL
79+
#if NAPI_VERSION >= 4
8080
napi_queue_full,
8181
napi_closing,
82-
#endif // NAPI_EXPERIMENTAL
82+
#endif // NAPI_VERSION >= 4
8383
} napi_status;
8484

85-
#ifdef NAPI_EXPERIMENTAL
85+
#if NAPI_VERSION >= 4
8686
typedef enum {
8787
napi_tsfn_release,
8888
napi_tsfn_abort
@@ -92,7 +92,7 @@ typedef enum {
9292
napi_tsfn_nonblocking,
9393
napi_tsfn_blocking
9494
} napi_threadsafe_function_call_mode;
95-
#endif // NAPI_EXPERIMENTAL
95+
#endif // NAPI_VERSION >= 4
9696

9797
typedef napi_value (*napi_callback)(napi_env env,
9898
napi_callback_info info);
@@ -105,12 +105,12 @@ typedef void (*napi_async_complete_callback)(napi_env env,
105105
napi_status status,
106106
void* data);
107107

108-
#ifdef NAPI_EXPERIMENTAL
108+
#if NAPI_VERSION >= 4
109109
typedef void (*napi_threadsafe_function_call_js)(napi_env env,
110110
napi_value js_callback,
111111
void* context,
112112
void* data);
113-
#endif // NAPI_EXPERIMENTAL
113+
#endif // NAPI_VERSION >= 4
114114

115115
typedef struct {
116116
// One of utf8name or name should be NULL.

src/node_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@
108108
#define NODE_MODULE_VERSION 57
109109

110110
// the NAPI_VERSION provided by this version of the runtime
111-
#define NAPI_VERSION 3
111+
#define NAPI_VERSION 4
112112

113113
#endif // SRC_NODE_VERSION_H_

test/addons-napi/test_general/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ assert.notStrictEqual(test_general.testGetPrototype(baseObject),
3333
test_general.testGetPrototype(extendedObject));
3434

3535
// test version management functions
36-
// expected version is currently 3
37-
assert.strictEqual(test_general.testGetVersion(), 3);
36+
// expected version is currently 4
37+
assert.strictEqual(test_general.testGetVersion(), 4);
3838

3939
const [ major, minor, patch, release ] = test_general.testGetNodeVersion();
4040
assert.strictEqual(process.version.split('-')[0],

test/addons-napi/test_threadsafe_function/binding.c

Lines changed: 0 additions & 1 deletion

0 commit comments

Comments
 (0)