mirror of
https://github.com/janet-lang/janet
synced 2025-01-03 12:20:26 +00:00
Update janet_interpreter_interrupt to use new atomics
This commit is contained in:
parent
af7ed4322e
commit
51a75e1872
@ -62,18 +62,10 @@ void janet_vm_load(JanetVM *from) {
|
|||||||
* use NULL to interrupt the current VM when convenient */
|
* use NULL to interrupt the current VM when convenient */
|
||||||
void janet_interpreter_interrupt(JanetVM *vm) {
|
void janet_interpreter_interrupt(JanetVM *vm) {
|
||||||
vm = vm ? vm : &janet_vm;
|
vm = vm ? vm : &janet_vm;
|
||||||
#ifdef JANET_WINDOWS
|
janet_atomic_inc(&vm->auto_suspend);
|
||||||
InterlockedIncrement(&vm->auto_suspend);
|
|
||||||
#else
|
|
||||||
__atomic_add_fetch(&vm->auto_suspend, 1, __ATOMIC_RELAXED);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void janet_interpreter_interrupt_handled(JanetVM *vm) {
|
void janet_interpreter_interrupt_handled(JanetVM *vm) {
|
||||||
vm = vm ? vm : &janet_vm;
|
vm = vm ? vm : &janet_vm;
|
||||||
#ifdef JANET_WINDOWS
|
janet_atomic_dec(&vm->auto_suspend);
|
||||||
InterlockedDecrement(&vm->auto_suspend);
|
|
||||||
#else
|
|
||||||
__atomic_add_fetch(&vm->auto_suspend, -1, __ATOMIC_RELAXED);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ struct JanetVM {
|
|||||||
|
|
||||||
/* If this flag is true, suspend on function calls and backwards jumps.
|
/* If this flag is true, suspend on function calls and backwards jumps.
|
||||||
* When this occurs, this flag will be reset to 0. */
|
* When this occurs, this flag will be reset to 0. */
|
||||||
volatile int32_t auto_suspend;
|
volatile JanetAtomicInt auto_suspend;
|
||||||
|
|
||||||
/* The current running fiber on the current thread.
|
/* The current running fiber on the current thread.
|
||||||
* Set and unset by functions in vm.c */
|
* Set and unset by functions in vm.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user