{
CommonData common;
guint16 class_size;
- guint init_state : 4;
+ int volatile init_state; /* atomic - g_type_class_ref reads it unlocked */
GBaseInitFunc class_init_base;
GBaseFinalizeFunc class_finalize_base;
GClassInitFunc class_init;
{
CommonData common;
guint16 class_size;
- guint init_state : 4;
+ int volatile init_state; /* atomic - g_type_class_ref reads it unlocked */
GBaseInitFunc class_init_base;
GBaseFinalizeFunc class_finalize_base;
GClassInitFunc class_init;
class = g_malloc0 (node->data->class.class_size);
node->data->class.class = class;
- node->data->class.init_state = BASE_CLASS_INIT;
+ g_atomic_int_set (&node->data->class.init_state, BASE_CLASS_INIT);
if (pclass)
{
G_WRITE_LOCK (&type_rw_lock);
- node->data->class.init_state = BASE_IFACE_INIT;
+ g_atomic_int_set (&node->data->class.init_state, BASE_IFACE_INIT);
/* Before we initialize the class, base initialize all interfaces, either
* from parent, or through our holder info
i++;
}
- node->data->class.init_state = CLASS_INIT;
+ g_atomic_int_set (&node->data->class.init_state, CLASS_INIT);
G_WRITE_UNLOCK (&type_rw_lock);
G_WRITE_LOCK (&type_rw_lock);
- node->data->class.init_state = IFACE_INIT;
+ g_atomic_int_set (&node->data->class.init_state, IFACE_INIT);
/* finish initializing the interfaces through our holder info.
* inherited interfaces are already init_state == INITIALIZED, because
i++;
}
- node->data->class.init_state = INITIALIZED;
+ g_atomic_int_set (&node->data->class.init_state, INITIALIZED);
}
static void
G_WRITE_LOCK (&type_rw_lock);
node = lookup_type_node_I (type);
if (node && node->is_classed && node->data &&
- node->data->class.class &&
- node->data->class.init_state == INITIALIZED)
+ g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
{
type_data_ref_Wm (node);
G_WRITE_UNLOCK (&type_rw_lock);
node = lookup_type_node_I (type);
G_READ_LOCK (&type_rw_lock);
- if (node && node->is_classed && node->data && node->data->class.class) /* ref_count _may_ be 0 */
+ if (node && node->is_classed && node->data &&
+ g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
+ /* ref_count _may_ be 0 */
class = node->data->class.class;
else
class = NULL;
G_READ_LOCK (&type_rw_lock);
if (node && node->is_classed && node->data &&
/* peek only static types: */ node->plugin == NULL &&
- node->data->class.class) /* ref_count _may_ be 0 */
+ g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
+ /* ref_count _may_ be 0 */
class = node->data->class.class;
else
class = NULL;