#include <sys/wait.h>
#include <stdarg.h>
#include <string.h>
+#include <pthread.h>
#include "config.h"
guint seed_debug_flags = 0; /* global seed debug flag */
gboolean seed_arg_print_version = FALSE; // Flag to print version and quit
-__thread JSObjectRef seed_next_gobject_wrapper = NULL;
-
+pthread_key_t seed_next_gobject_wrapper_key;
#ifdef SEED_ENABLE_DEBUG
static const GDebugKey seed_debug_keys[] = {
SEED_NOTE (INITIALIZATION, "Constructing object of type %s",
g_type_name (type));
- seed_next_gobject_wrapper = seed_make_wrapper_for_type (ctx, type);
+
+ pthread_setspecific (seed_next_gobject_wrapper_key,
+ seed_make_wrapper_for_type (ctx, type));
while (i < nparams)
{
if (param_spec == NULL)
{
- JSObjectSetProperty (ctx, seed_next_gobject_wrapper, jsprop_name,
+ JSObjectSetProperty (ctx, pthread_getspecific(seed_next_gobject_wrapper_key), jsprop_name,
jsprop_value, 0, NULL);
++i;
continue;
{
g_free (params);
JSPropertyNameArrayRelease (jsprops);
- seed_next_gobject_wrapper = NULL;
+ pthread_setspecific(seed_next_gobject_wrapper_key, NULL);
return 0;
}
params[ri].name = prop_name;
gsize length;
gsize i, len;
- if (seed_next_gobject_wrapper || JSValueIsNull (context, value))
+ if (pthread_getspecific(seed_next_gobject_wrapper_key) ||
+ JSValueIsNull (context, value))
return 0;
seed_init (gint * argc, gchar *** argv)
{
context_group = JSContextGroupCreate ();
+ pthread_key_create(&seed_next_gobject_wrapper_key, NULL);
return seed_init_with_context_group (argc, argv, context_group);
}
#include "seed-private.h"
#include <dlfcn.h>
+#include <pthread.h>
JSClassRef gobject_class;
JSClassRef gobject_method_class;
if (user_data)
return user_data;
- if (seed_next_gobject_wrapper)
- js_ref = seed_next_gobject_wrapper;
+ if (pthread_getspecific(seed_next_gobject_wrapper_key))
+ js_ref = pthread_getspecific(seed_next_gobject_wrapper_key);
else
js_ref = seed_make_wrapper_for_type (ctx, type);
seed_add_signals_to_object (ctx, js_ref, object);
- seed_next_gobject_wrapper = NULL;
+ pthread_setspecific(seed_next_gobject_wrapper_key, NULL);
return js_ref;
}