| 1 |
/* |
| 2 |
Copyright Node.js contributors. All rights reserved. |
| 3 |
|
| 4 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
of this software and associated documentation files (the "Software"), to |
| 6 |
deal in the Software without restriction, including without limitation the |
| 7 |
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 |
sell copies of the Software, and to permit persons to whom the Software is |
| 9 |
furnished to do so, subject to the following conditions: |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included in |
| 12 |
all copies or substantial portions of the Software. |
| 13 |
|
| 14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 |
IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
// Node does not include the headers for these functions when compiling for WASM, so add them here. |
| 24 |
#ifdef __wasm32__ |
| 25 |
extern "C" { |
| 26 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 27 |
napi_create_threadsafe_function(napi_env env, |
| 28 |
napi_value func, |
| 29 |
napi_value async_resource, |
| 30 |
napi_value async_resource_name, |
| 31 |
size_t max_queue_size, |
| 32 |
size_t initial_thread_count, |
| 33 |
void* thread_finalize_data, |
| 34 |
napi_finalize thread_finalize_cb, |
| 35 |
void* context, |
| 36 |
napi_threadsafe_function_call_js call_js_cb, |
| 37 |
napi_threadsafe_function* result); |
| 38 |
|
| 39 |
NAPI_EXTERN napi_status NAPI_CDECL napi_get_threadsafe_function_context( |
| 40 |
napi_threadsafe_function func, void** result); |
| 41 |
|
| 42 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 43 |
napi_call_threadsafe_function(napi_threadsafe_function func, |
| 44 |
void* data, |
| 45 |
napi_threadsafe_function_call_mode is_blocking); |
| 46 |
|
| 47 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 48 |
napi_acquire_threadsafe_function(napi_threadsafe_function func); |
| 49 |
|
| 50 |
NAPI_EXTERN napi_status NAPI_CDECL napi_release_threadsafe_function( |
| 51 |
napi_threadsafe_function func, napi_threadsafe_function_release_mode mode); |
| 52 |
|
| 53 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 54 |
napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); |
| 55 |
|
| 56 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 57 |
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); |
| 58 |
|
| 59 |
NAPI_EXTERN napi_status NAPI_CDECL |
| 60 |
napi_create_async_work(napi_env env, |
| 61 |
napi_value async_resource, |
| 62 |
napi_value async_resource_name, |
| 63 |
napi_async_execute_callback execute, |
| 64 |
napi_async_complete_callback complete, |
| 65 |
void* data, |
| 66 |
napi_async_work* result); |
| 67 |
NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work(napi_env env, |
| 68 |
napi_async_work work); |
| 69 |
NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env, |
| 70 |
napi_async_work work); |
| 71 |
NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env, |
| 72 |
napi_async_work work); |
| 73 |
} |
| 74 |
#endif |