[gjs/wip/ptomato/eval-thread-set: 2/2] WIP - gjs_eval_thread set
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/eval-thread-set: 2/2] WIP - gjs_eval_thread set
- Date: Tue, 7 Mar 2017 06:10:20 +0000 (UTC)
commit 1d737e423a74ad7512640459770ccfbcc3906f37
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Mar 6 22:09:45 2017 -0800
WIP - gjs_eval_thread set
gi/object.cpp | 5 +----
gjs/context-private.h | 2 ++
gjs/context.cpp | 10 ++++++++++
3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index bd7db75..9e1dd32 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -104,7 +104,6 @@ static bool weak_pointer_callback = false;
static std::set<ObjectInstance *> weak_pointer_list;
extern struct JSClass gjs_object_instance_class;
-static GThread *gjs_eval_thread;
static volatile gint pending_idle_toggles;
static std::set<ObjectInstance *> dissociate_list;
@@ -1203,7 +1202,7 @@ wrapped_gobj_toggle_notify(gpointer data,
* but there aren't many peculiar objects like that and it's
* not a big deal.
*/
- is_main_thread = (gjs_eval_thread == g_thread_self());
+ is_main_thread = (_gjs_context_get_eval_thread(context) == g_thread_self());
toggle_up_queued = toggle_idle_source_is_queued(gobj, TOGGLE_UP);
toggle_down_queued = toggle_idle_source_is_queued(gobj, TOGGLE_DOWN);
@@ -2707,8 +2706,6 @@ gjs_object_class_init(GObjectClass *klass,
klass->set_property = gjs_object_set_gproperty;
klass->get_property = gjs_object_get_gproperty;
- gjs_eval_thread = g_thread_self();
-
properties = (GPtrArray*) gjs_hash_table_for_gsize_lookup (class_init_properties, gtype);
if (properties != NULL) {
for (i = 0; i < properties->len; i++) {
diff --git a/gjs/context-private.h b/gjs/context-private.h
index 5b24b77..d2786db 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -37,6 +37,8 @@ void _gjs_context_schedule_gc_if_needed (GjsContext *js_context);
void _gjs_context_exit(GjsContext *js_context,
uint8_t exit_code);
+GThread *_gjs_context_get_eval_thread(GjsContext *js_context);
+
G_END_DECLS
#endif /* __GJS_CONTEXT_PRIVATE_H__ */
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 08292fb..051bd9d 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -69,6 +69,7 @@ struct _GjsContext {
JSRuntime *runtime;
JSContext *context;
JS::Heap<JSObject*> global;
+ GThread *eval_thread;
char *program_name;
@@ -489,6 +490,9 @@ gjs_context_constructed(GObject *object)
js_context->runtime = gjs_runtime_ref();
+ JS_AbortIfWrongThread(js_context->runtime);
+ js_context->eval_thread = g_thread_self();
+
js_context->context = JS_NewContext(js_context->runtime, 8192 /* stack chunk size */);
if (js_context->context == NULL)
g_error("Failed to create javascript context");
@@ -661,6 +665,12 @@ context_reset_exit(GjsContext *js_context)
js_context->exit_code = 0;
}
+GThread *
+_gjs_context_get_eval_thread(GjsContext *js_context)
+{
+ return js_context->eval_thread;
+}
+
/**
* gjs_context_maybe_gc:
* @context: a #GjsContext
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]