[gjs/297-prevent-accumulating-toggles] context: Clear toggle queue whenever a GC is scheduled
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/297-prevent-accumulating-toggles] context: Clear toggle queue whenever a GC is scheduled
- Date: Sun, 9 Aug 2020 22:41:22 +0000 (UTC)
commit 688a4293fa0044a3d279b406682c85aaf3081221
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Aug 9 15:37:16 2020 -0700
context: Clear toggle queue whenever a GC is scheduled
It seems that occasionally when using a GFileMonitor, toggle queue
notifications will arrive on a separate thread and get queued, faster
than they can be processed.
This ensures the toggle queue is drained every time we finish executing
JS code, which will hopefully make such a pile-up less likely.
Closes: #297
gjs/context-private.h | 2 +-
gjs/context.cpp | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gjs/context-private.h b/gjs/context-private.h
index ef8f28b6..3e33bb1a 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -228,7 +228,7 @@ class GjsContextPrivate : public JS::JobQueue {
const JS::HandleValueArray& args,
JS::MutableHandleValue rval);
- void schedule_gc(void) { schedule_gc_internal(true); }
+ void schedule_gc();
void schedule_gc_if_needed(void);
void exit(uint8_t exit_code);
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 747f6f38..cf7100b4 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -24,6 +24,7 @@
#include <config.h>
#include <signal.h> // for sigaction, SIGUSR1, sa_handler
+#include <stdint.h>
#include <stdio.h> // for FILE, fclose, size_t
#include <string.h> // for memset
@@ -35,6 +36,7 @@
#include <new>
#include <string> // for u16string
+#include <type_traits> // for remove_reference<>::type
#include <unordered_map>
#include <utility> // for move
#include <vector>
@@ -616,6 +618,11 @@ void GjsContextPrivate::schedule_gc_internal(bool force_gc) {
nullptr);
}
+void GjsContextPrivate::schedule_gc() {
+ gjs_object_clear_toggles();
+ schedule_gc_internal(true);
+}
+
/*
* GjsContextPrivate::schedule_gc_if_needed:
*
@@ -623,6 +630,8 @@ void GjsContextPrivate::schedule_gc_internal(bool force_gc) {
* schedules a full GC in the next idle time.
*/
void GjsContextPrivate::schedule_gc_if_needed(void) {
+ gjs_object_clear_toggles();
+
// We call JS_MaybeGC immediately, but defer a check for a full GC cycle
// to an idle handler.
JS_MaybeGC(m_cx);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]