emnapi 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/include/uv.h CHANGED
@@ -40,6 +40,7 @@ struct uv_req_s {
40
40
  UV_REQ_FIELDS
41
41
  };
42
42
 
43
+ UV_EXTERN void uv_library_shutdown(void);
43
44
  UV_EXTERN uv_loop_t* uv_default_loop(void);
44
45
  UV_EXTERN int uv_loop_init(uv_loop_t* loop);
45
46
  UV_EXTERN int uv_loop_close(uv_loop_t* loop);
@@ -53,6 +54,7 @@ UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
53
54
  UV_EXTERN int uv_cond_init(uv_cond_t* cond);
54
55
  UV_EXTERN void uv_cond_signal(uv_cond_t* cond);
55
56
  UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
57
+ UV_EXTERN void uv_cond_destroy(uv_cond_t* cond);
56
58
 
57
59
  UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
58
60
 
@@ -75,6 +77,7 @@ UV_EXTERN int uv_mutex_init(uv_mutex_t* mutex);
75
77
  UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
76
78
  UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
77
79
  UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
80
+ UV_EXTERN void uv_mutex_destroy(uv_mutex_t* cond);
78
81
 
79
82
  typedef void (*uv_thread_cb)(void* arg);
80
83
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emnapi",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Node-API implementation for Emscripten",
5
5
  "main": "index.js",
6
6
  "peerDependencies": {
@@ -180,34 +180,34 @@ static void post(QUEUE* q, enum uv__work_kind kind) {
180
180
  }
181
181
 
182
182
 
183
- // #ifdef __MVS__
184
- // /* TODO(itodorov) - zos: revisit when Woz compiler is available. */
185
- // __attribute__((destructor))
186
- // #endif
187
- // void uv__threadpool_cleanup(void) {
188
- // unsigned int i;
183
+ #ifdef __MVS__
184
+ /* TODO(itodorov) - zos: revisit when Woz compiler is available. */
185
+ __attribute__((destructor))
186
+ #endif
187
+ void uv__threadpool_cleanup(void) {
188
+ unsigned int i;
189
189
 
190
- // if (nthreads == 0)
191
- // return;
190
+ if (nthreads == 0)
191
+ return;
192
192
 
193
- // #ifndef __MVS__
194
- // /* TODO(gabylb) - zos: revisit when Woz compiler is available. */
195
- // post(&exit_message, UV__WORK_CPU);
196
- // #endif
193
+ #ifndef __MVS__
194
+ /* TODO(gabylb) - zos: revisit when Woz compiler is available. */
195
+ post(&exit_message, UV__WORK_CPU);
196
+ #endif
197
197
 
198
- // for (i = 0; i < nthreads; i++)
199
- // if (uv_thread_join(threads + i))
200
- // abort();
198
+ for (i = 0; i < nthreads; i++)
199
+ if (uv_thread_join(threads + i))
200
+ abort();
201
201
 
202
- // if (threads != default_threads)
203
- // free(threads);
202
+ if (threads != default_threads)
203
+ free(threads);
204
204
 
205
- // uv_mutex_destroy(&mutex);
206
- // uv_cond_destroy(&cond);
205
+ uv_mutex_destroy(&mutex);
206
+ uv_cond_destroy(&cond);
207
207
 
208
- // threads = NULL;
209
- // nthreads = 0;
210
- // }
208
+ threads = NULL;
209
+ nthreads = 0;
210
+ }
211
211
 
212
212
  EMNAPI_EXTERN int _emnapi_async_work_pool_size();
213
213
 
@@ -98,6 +98,11 @@ void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
98
98
  abort();
99
99
  }
100
100
 
101
+ void uv_cond_destroy(uv_cond_t* cond) {
102
+ if (pthread_cond_destroy(cond))
103
+ abort();
104
+ }
105
+
101
106
  int uv_thread_create_ex(uv_thread_t* tid,
102
107
  void* params,
103
108
  void (*entry)(void *arg),
@@ -48,4 +48,23 @@ int uv_loop_close(uv_loop_t* loop) {
48
48
  return 0;
49
49
  }
50
50
 
51
+ #if defined(__GNUC__) && !defined(_WIN32)
52
+ __attribute__((destructor))
53
+ #endif
54
+ void uv_library_shutdown(void) {
55
+ static int was_shutdown;
56
+
57
+ if (uv__exchange_int_relaxed(&was_shutdown, 1))
58
+ return;
59
+
60
+ // uv__process_title_cleanup();
61
+ // uv__signal_cleanup();
62
+ // #ifdef __MVS__
63
+ // /* TODO(itodorov) - zos: revisit when Woz compiler is available. */
64
+ // uv__os390_cleanup();
65
+ // #else
66
+ uv__threadpool_cleanup();
67
+ // #endif
68
+ }
69
+
51
70
  #endif
@@ -18,6 +18,9 @@
18
18
  #include <assert.h>
19
19
  #include "uv.h"
20
20
  #include "queue.h"
21
+ #ifndef _MSC_VER
22
+ # include <stdatomic.h>
23
+ #endif
21
24
 
22
25
  #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
23
26
  // #define offsetof(s, m) __builtin_offsetof(s, m)
@@ -53,12 +56,16 @@
53
56
  } \
54
57
  while (0)
55
58
 
59
+ #define uv__exchange_int_relaxed(p, v) \
60
+ atomic_exchange_explicit((_Atomic int*)(p), v, memory_order_relaxed)
61
+
56
62
  enum uv__work_kind {
57
63
  UV__WORK_CPU,
58
64
  UV__WORK_FAST_IO,
59
65
  UV__WORK_SLOW_IO
60
66
  };
61
67
 
68
+ void uv__threadpool_cleanup(void);
62
69
  void uv__work_done(uv_async_t* handle);
63
70
  void uv__loop_close(uv_loop_t* loop);
64
71
  void uv__async_close(uv_async_t* handle);