Skip to content

Commit 2b18582

Browse files
Gabriel Schulhoftargos
Gabriel Schulhof
authored andcommitted
n-api: mark thread-safe function as stable
Fixes: #24249 PR-URL: #25556 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 5440f9d commit 2b18582

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

doc/api/n-api.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ This is an opaque pointer that is used to represent a JavaScript value.
282282

283283
### napi_threadsafe_function
284284

285-
> Stability: 1 - Experimental
285+
> Stability: 2 - Stable
286286

287287
This is an opaque pointer that represents a JavaScript function which can be
288288
called asynchronously from multiple threads via
289289
`napi_call_threadsafe_function()`.
290290

291291
### napi_threadsafe_function_release_mode
292292

293-
> Stability: 1 - Experimental
293+
> Stability: 2 - Stable
294294

295295
A value to be given to `napi_release_threadsafe_function()` to indicate whether
296296
the thread-safe function is to be closed immediately (`napi_tsfn_abort`) or
@@ -305,7 +305,7 @@ typedef enum {
305305

306306
### napi_threadsafe_function_call_mode
307307

308-
> Stability: 1 - Experimental
308+
> Stability: 2 - Stable
309309

310310
A value to be given to `napi_call_threadsafe_function()` to indicate whether
311311
the call should block whenever the queue associated with the thread-safe
@@ -400,7 +400,7 @@ typedef void (*napi_async_complete_callback)(napi_env env,
400400

401401
#### napi_threadsafe_function_call_js
402402

403-
> Stability: 1 - Experimental
403+
> Stability: 2 - Stable
404404

405405
Function pointer used with asynchronous thread-safe function calls. The callback
406406
will be called on the main thread. Its purpose is to use a data item arriving
@@ -4526,7 +4526,7 @@ prevent the event loop from exiting. The APIs `napi_ref_threadsafe_function` and
45264526

45274527
### napi_create_threadsafe_function
45284528

4529-
> Stability: 1 - Experimental
4529+
> Stability: 2 - Stable
45304530

45314531
<!-- YAML
45324532
added: v10.6.0
@@ -4569,7 +4569,7 @@ parameters and with `undefined` as its `this` value.
45694569

45704570
### napi_get_threadsafe_function_context
45714571

4572-
> Stability: 1 - Experimental
4572+
> Stability: 2 - Stable
45734573

45744574
<!-- YAML
45754575
added: v10.6.0
@@ -4587,7 +4587,7 @@ This API may be called from any thread which makes use of `func`.
45874587

45884588
### napi_call_threadsafe_function
45894589

4590-
> Stability: 1 - Experimental
4590+
> Stability: 2 - Stable
45914591

45924592
<!-- YAML
45934593
added: v10.6.0
@@ -4615,7 +4615,7 @@ This API may be called from any thread which makes use of `func`.
46154615

46164616
### napi_acquire_threadsafe_function
46174617

4618-
> Stability: 1 - Experimental
4618+
> Stability: 2 - Stable
46194619

46204620
<!-- YAML
46214621
added: v10.6.0
@@ -4637,7 +4637,7 @@ This API may be called from any thread which will start making use of `func`.
46374637

46384638
### napi_release_threadsafe_function
46394639

4640-
> Stability: 1 - Experimental
4640+
> Stability: 2 - Stable
46414641

46424642
<!-- YAML
46434643
added: v10.6.0
@@ -4665,7 +4665,7 @@ This API may be called from any thread which will stop making use of `func`.
46654665

46664666
### napi_ref_threadsafe_function
46674667

4668-
> Stability: 1 - Experimental
4668+
> Stability: 2 - Stable
46694669

46704670
<!-- YAML
46714671
added: v10.6.0
@@ -4686,7 +4686,7 @@ This API may only be called from the main thread.
46864686

46874687
### napi_unref_threadsafe_function
46884688

4689-
> Stability: 1 - Experimental
4689+
> Stability: 2 - Stable
46904690

46914691
<!-- YAML
46924692
added: v10.6.0

src/js_native_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
1313
#else
1414
// The baseline version for N-API
15-
#define NAPI_VERSION 3
15+
#define NAPI_VERSION 4
1616
#endif
1717
#endif
1818

src/node_api.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env,
192192

193193
#endif // NAPI_VERSION >= 3
194194

195-
#ifdef NAPI_EXPERIMENTAL
195+
#if NAPI_VERSION >= 4
196196

197197
// Calling into JS from other threads
198198
NAPI_EXTERN napi_status
@@ -230,7 +230,7 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
230230
NAPI_EXTERN napi_status
231231
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
232232

233-
#endif // NAPI_EXPERIMENTAL
233+
#endif // NAPI_VERSION >= 4
234234

235235
EXTERN_C_END
236236

src/node_api_types.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
typedef struct napi_callback_scope__* napi_callback_scope;
77
typedef struct napi_async_context__* napi_async_context;
88
typedef struct napi_async_work__* napi_async_work;
9-
#ifdef NAPI_EXPERIMENTAL
9+
#if NAPI_VERSION >= 4
1010
typedef struct napi_threadsafe_function__* napi_threadsafe_function;
11-
#endif // NAPI_EXPERIMENTAL
11+
#endif // NAPI_VERSION >= 4
1212

13-
#ifdef NAPI_EXPERIMENTAL
13+
#ifdef NAPI_VERSION >= 4
1414
typedef enum {
1515
napi_tsfn_release,
1616
napi_tsfn_abort
@@ -20,19 +20,19 @@ typedef enum {
2020
napi_tsfn_nonblocking,
2121
napi_tsfn_blocking
2222
} napi_threadsafe_function_call_mode;
23-
#endif // NAPI_EXPERIMENTAL
23+
#endif // NAPI_VERSION >= 4
2424

2525
typedef void (*napi_async_execute_callback)(napi_env env,
2626
void* data);
2727
typedef void (*napi_async_complete_callback)(napi_env env,
2828
napi_status status,
2929
void* data);
30-
#ifdef NAPI_EXPERIMENTAL
30+
#ifdef NAPI_VERSION >= 4
3131
typedef void (*napi_threadsafe_function_call_js)(napi_env env,
3232
napi_value js_callback,
3333
void* context,
3434
void* data);
35-
#endif // NAPI_EXPERIMENTAL
35+
#endif // NAPI_VERSION >= 4
3636

3737
typedef struct {
3838
uint32_t major;

src/node_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@
117117
#define NODE_MODULE_VERSION 67
118118

119119
// the NAPI_VERSION provided by this version of the runtime
120-
#define NAPI_VERSION 3
120+
#define NAPI_VERSION 4
121121

122122
#endif // SRC_NODE_VERSION_H_

test/js-native-api/test_general/test.js

+2-2
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
[
4040
123,

test/node-api/test_threadsafe_function/binding.c

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// which, in turn, may affect the ABI stability of the project despite its use
55
// of N-API.
66
#include <uv.h>
7-
#define NAPI_EXPERIMENTAL
87
#include <node_api.h>
98
#include "../../js-native-api/common.h"
109

0 commit comments

Comments
 (0)