File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,11 @@ extern char **environ;
87
87
88
88
#ifdef USE_WORKER
89
89
#include <pthread.h>
90
- #include "quickjs-c-atomics.h"
91
90
#endif
92
91
93
92
#include "cutils.h"
94
93
#include "list.h"
94
+ #include "quickjs-c-atomics.h"
95
95
#include "quickjs-libc.h"
96
96
97
97
#define MAX_SAFE_INTEGER (((int64_t) 1 << 53) - 1)
@@ -167,7 +167,7 @@ typedef struct JSThreadState {
167
167
} JSThreadState ;
168
168
169
169
static uint64_t os_pending_signals ;
170
- static int ( * os_poll_func )( JSContext * ctx ) ;
170
+ static _Atomic int can_js_os_poll ;
171
171
172
172
static void js_std_dbuf_init (JSContext * ctx , DynBuf * s )
173
173
{
@@ -3827,7 +3827,7 @@ static const JSCFunctionListEntry js_os_funcs[] = {
3827
3827
3828
3828
static int js_os_init (JSContext * ctx , JSModuleDef * m )
3829
3829
{
3830
- os_poll_func = js_os_poll ;
3830
+ atomic_store ( & can_js_os_poll , TRUE) ;
3831
3831
3832
3832
#ifdef USE_WORKER
3833
3833
{
@@ -4058,7 +4058,7 @@ JSValue js_std_loop(JSContext *ctx)
4058
4058
}
4059
4059
}
4060
4060
4061
- if (!os_poll_func || os_poll_func (ctx ))
4061
+ if (!atomic_load ( & can_js_os_poll ) || js_os_poll (ctx ))
4062
4062
break ;
4063
4063
}
4064
4064
done :
@@ -4090,8 +4090,8 @@ JSValue js_std_await(JSContext *ctx, JSValue obj)
4090
4090
if (err < 0 ) {
4091
4091
js_std_dump_error (ctx1 );
4092
4092
}
4093
- if (os_poll_func )
4094
- os_poll_func (ctx );
4093
+ if (atomic_load ( & can_js_os_poll ) )
4094
+ js_os_poll (ctx );
4095
4095
} else {
4096
4096
/* not a promise */
4097
4097
ret = obj ;
You can’t perform that action at this time.
0 commit comments