mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
Try to use atomics inside signal handler for ref count.
This commit is contained in:
parent
91712add3d
commit
ca4c1e4259
@ -603,11 +603,19 @@ void janet_addtimeout(double sec) {
|
||||
}
|
||||
|
||||
void janet_ev_inc_refcount(void) {
|
||||
janet_vm.extra_listeners++;
|
||||
#ifdef JANET_WINDOWS
|
||||
InterlockedIncrement(&janet_vm.extra_listeners);
|
||||
#else
|
||||
__atomic_add_fetch(&janet_vm.extra_listeners, 1, __ATOMIC_RELAXED);
|
||||
#endif
|
||||
}
|
||||
|
||||
void janet_ev_dec_refcount(void) {
|
||||
janet_vm.extra_listeners--;
|
||||
#ifdef JANET_WINDOWS
|
||||
InterlockedDecrement(&janet_vm.extra_listeners);
|
||||
#else
|
||||
__atomic_add_fetch(&janet_vm.extra_listeners, -1, __ATOMIC_RELAXED);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Channels */
|
||||
|
@ -157,7 +157,7 @@ struct JanetVM {
|
||||
JanetListenerState **listeners;
|
||||
size_t listener_count;
|
||||
size_t listener_cap;
|
||||
size_t extra_listeners;
|
||||
volatile size_t extra_listeners; /* used in signal handler, must be volatile */
|
||||
JanetTable threaded_abstracts; /* All abstract types that can be shared between threads (used in this thread) */
|
||||
JanetTable active_tasks; /* All possibly live task fibers - used just for tracking */
|
||||
JanetTable signal_handlers;
|
||||
|
Loading…
Reference in New Issue
Block a user