aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-node.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@src.gnome.org>2003-12-17 01:29:43 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-12-17 01:29:43 +0800
commit7a407a918297b8c54ee79174aac54bc84de97d29 (patch)
tree2b23c9bb51f5b388861697b0470652ec5a5e1e44 /lib/ephy-node.c
parent7339c460e72364aad2de893ab3c13549efc01d9b (diff)
downloadgsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar.gz
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar.bz2
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar.lz
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar.xz
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.tar.zst
gsoc2013-epiphany-7a407a918297b8c54ee79174aac54bc84de97d29.zip
*** empty log message ***
Diffstat (limited to 'lib/ephy-node.c')
-rw-r--r--lib/ephy-node.c247
1 files changed, 0 insertions, 247 deletions
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 35cbe6936..6194cb60f 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -34,7 +34,6 @@
#include "ephy-node.h"
#include "ephy-string.h"
-#include "ephy-thread-helpers.h"
typedef struct
{
@@ -53,8 +52,6 @@ typedef struct
struct EphyNode
{
- GStaticRWLock *lock;
-
int ref_count;
gulong id;
@@ -76,41 +73,6 @@ typedef struct
va_list valist;
} ENESCData;
-/* evillish hacks to temporarily readlock->writelock and v.v. */
-static inline void
-write_lock_to_read_lock (EphyNode *node)
-{
- g_static_mutex_lock (&node->lock->mutex);
- node->lock->read_counter++;
- g_static_mutex_unlock (&node->lock->mutex);
-
- g_static_rw_lock_writer_unlock (node->lock);
-}
-
-static inline void
-read_lock_to_write_lock (EphyNode *node)
-{
- g_static_mutex_lock (&node->lock->mutex);
- node->lock->read_counter--;
- g_static_mutex_unlock (&node->lock->mutex);
-
- g_static_rw_lock_writer_lock (node->lock);
-}
-
-static inline void
-lock_gdk (void)
-{
- if (ephy_thread_helpers_in_main_thread () == FALSE)
- GDK_THREADS_ENTER ();
-}
-
-static inline void
-unlock_gdk (void)
-{
- if (ephy_thread_helpers_in_main_thread () == FALSE)
- GDK_THREADS_LEAVE ();
-}
-
static gboolean
int_equal (gconstpointer a,
gconstpointer b)
@@ -208,9 +170,6 @@ ephy_node_finalize (EphyNode *node)
g_ptr_array_free (node->children, TRUE);
- g_static_rw_lock_free (node->lock);
- g_free (node->lock);
-
g_free (node);
}
@@ -241,22 +200,13 @@ real_remove_child (EphyNode *node,
borked_node = g_ptr_array_index (node->children, i);
- g_static_rw_lock_writer_lock (borked_node->lock);
borked_node_info = g_hash_table_lookup (borked_node->parents,
GINT_TO_POINTER (node->id));
borked_node_info->index--;
-
- g_static_rw_lock_writer_unlock (borked_node->lock);
}
- write_lock_to_read_lock (node);
- write_lock_to_read_lock (child);
-
ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index);
-
- read_lock_to_write_lock (node);
- read_lock_to_write_lock (child);
}
if (remove_from_child) {
@@ -270,11 +220,7 @@ remove_child (long id,
EphyNodeParent *node_info,
EphyNode *node)
{
- g_static_rw_lock_writer_lock (node_info->node->lock);
-
real_remove_child (node_info->node, node, TRUE, FALSE);
-
- g_static_rw_lock_writer_unlock (node_info->node->lock);
}
static void
@@ -302,14 +248,8 @@ ephy_node_dispose (EphyNode *node)
{
guint i;
- write_lock_to_read_lock (node);
-
ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
- read_lock_to_write_lock (node);
-
- lock_gdk ();
-
/* remove from DAG */
g_hash_table_foreach (node->parents,
(GHFunc) remove_child,
@@ -320,22 +260,14 @@ ephy_node_dispose (EphyNode *node)
child = g_ptr_array_index (node->children, i);
- g_static_rw_lock_writer_lock (child->lock);
-
real_remove_child (node, child, FALSE, TRUE);
-
- g_static_rw_lock_writer_unlock (child->lock);
}
- g_static_rw_lock_writer_unlock (node->lock);
-
g_hash_table_foreach (node->signals,
(GHFunc) unref_signal_objects,
node);
_ephy_node_db_remove_id (node->db, node->id);
-
- unlock_gdk ();
}
EphyNode *
@@ -359,9 +291,6 @@ ephy_node_new_with_id (EphyNodeDb *db, gulong reserved_id)
node = g_new0 (EphyNode, 1);
- node->lock = g_new0 (GStaticRWLock, 1);
- g_static_rw_lock_init (node->lock);
-
node->ref_count = 0;
node->id = reserved_id;
@@ -403,12 +332,8 @@ ephy_node_get_id (EphyNode *node)
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_static_rw_lock_reader_lock (node->lock);
-
ret = node->id;
- g_static_rw_lock_reader_unlock (node->lock);
-
return ret;
}
@@ -417,11 +342,7 @@ ephy_node_ref (EphyNode *node)
{
g_return_if_fail (EPHY_IS_NODE (node));
- g_static_rw_lock_writer_lock (node->lock);
-
node->ref_count++;
-
- g_static_rw_lock_writer_unlock (node->lock);
}
void
@@ -429,44 +350,20 @@ ephy_node_unref (EphyNode *node)
{
g_return_if_fail (EPHY_IS_NODE (node));
- g_static_rw_lock_writer_lock (node->lock);
-
node->ref_count--;
if (node->ref_count <= 0) {
ephy_node_dispose (node);
ephy_node_finalize (node);
- } else {
- g_static_rw_lock_writer_unlock (node->lock);
}
}
-void
-ephy_node_freeze (EphyNode *node)
-{
- g_return_if_fail (EPHY_IS_NODE (node));
-
- g_static_rw_lock_reader_lock (node->lock);
-}
-
-void
-ephy_node_thaw (EphyNode *node)
-{
- g_return_if_fail (EPHY_IS_NODE (node));
-
- g_static_rw_lock_reader_unlock (node->lock);
-}
-
static void
child_changed (gulong id,
EphyNodeParent *node_info,
EphyNode *node)
{
- g_static_rw_lock_reader_lock (node_info->node->lock);
-
ephy_node_emit_signal (node_info->node, EPHY_NODE_CHILD_CHANGED, node);
-
- g_static_rw_lock_reader_unlock (node_info->node->lock);
}
static inline void
@@ -500,25 +397,15 @@ ephy_node_set_property (EphyNode *node,
g_return_if_fail (property_id >= 0);
g_return_if_fail (value != NULL);
- lock_gdk ();
-
- g_static_rw_lock_writer_lock (node->lock);
-
new = g_new0 (GValue, 1);
g_value_init (new, G_VALUE_TYPE (value));
g_value_copy (value, new);
real_set_property (node, property_id, new);
- write_lock_to_read_lock (node);
-
g_hash_table_foreach (node->parents,
(GHFunc) child_changed,
node);
-
- g_static_rw_lock_reader_unlock (node->lock);
-
- unlock_gdk ();
}
gboolean
@@ -532,24 +419,18 @@ ephy_node_get_property (EphyNode *node,
g_return_val_if_fail (property_id >= 0, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return FALSE;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return FALSE;
}
g_value_init (value, G_VALUE_TYPE (ret));
g_value_copy (ret, value);
- g_static_rw_lock_reader_unlock (node->lock);
-
return TRUE;
}
@@ -563,23 +444,17 @@ ephy_node_get_property_string (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
g_return_val_if_fail (property_id >= 0, NULL);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return NULL;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return NULL;
}
retval = g_value_get_string (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -593,23 +468,17 @@ ephy_node_get_property_boolean (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
g_return_val_if_fail (property_id >= 0, FALSE);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return FALSE;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return FALSE;
}
retval = g_value_get_boolean (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -623,23 +492,17 @@ ephy_node_get_property_long (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (property_id >= 0, -1);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
retval = g_value_get_long (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -653,23 +516,17 @@ ephy_node_get_property_int (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (property_id >= 0, -1);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
retval = g_value_get_int (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -683,23 +540,17 @@ ephy_node_get_property_double (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (property_id >= 0, -1);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
retval = g_value_get_double (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -713,23 +564,17 @@ ephy_node_get_property_float (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (property_id >= 0, -1);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return -1;
}
retval = g_value_get_float (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -743,23 +588,17 @@ ephy_node_get_property_node (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
g_return_val_if_fail (property_id >= 0, NULL);
- g_static_rw_lock_reader_lock (node->lock);
-
if (property_id >= node->properties->len) {
- g_static_rw_lock_reader_unlock (node->lock);
return NULL;
}
ret = g_ptr_array_index (node->properties, property_id);
if (ret == NULL) {
- g_static_rw_lock_reader_unlock (node->lock);
return NULL;
}
retval = g_value_get_pointer (ret);
- g_static_rw_lock_reader_unlock (node->lock);
-
return retval;
}
@@ -784,10 +623,8 @@ write_parent (gulong id,
data->ret = xmlTextWriterStartElement (writer, "parent");
if (data->ret < 0) return;
- g_static_rw_lock_reader_lock (node_info->node->lock);
data->ret = xmlTextWriterWriteFormatAttribute
(writer, "id", "%ld", node_info->node->id);
- g_static_rw_lock_reader_unlock (node_info->node->lock);
if (data->ret < 0) return;
data->ret = xmlTextWriterEndElement (writer); /* parent */
@@ -806,8 +643,6 @@ ephy_node_write_to_xml(EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (writer != NULL, -1);
- g_static_rw_lock_reader_lock (node->lock);
-
/* start writing the node */
ret = xmlTextWriterStartElement (writer, "node");
if (ret < 0) goto out;
@@ -888,8 +723,6 @@ ephy_node_write_to_xml(EphyNode *node,
if (ret < 0) goto out;
out:
- g_static_rw_lock_reader_unlock (node->lock);
-
return ret >= 0 ? 0 : -1;
}
@@ -915,9 +748,6 @@ real_add_child (EphyNode *node,
node_info);
}
-/* this function assumes it's safe to not lock anything while loading,
- * this is at least true for the case where we're loading the library xml file
- * from the main loop */
EphyNode *
ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
{
@@ -1021,43 +851,20 @@ void
ephy_node_add_child (EphyNode *node,
EphyNode *child)
{
- lock_gdk ();
-
g_return_if_fail (EPHY_IS_NODE (node));
- g_static_rw_lock_writer_lock (node->lock);
- g_static_rw_lock_writer_lock (child->lock);
-
real_add_child (node, child);
- write_lock_to_read_lock (node);
- write_lock_to_read_lock (child);
-
ephy_node_emit_signal (node, EPHY_NODE_CHILD_ADDED, child);
-
- g_static_rw_lock_reader_unlock (node->lock);
- g_static_rw_lock_reader_unlock (child->lock);
-
- unlock_gdk ();
}
void
ephy_node_remove_child (EphyNode *node,
EphyNode *child)
{
- lock_gdk ();
-
g_return_if_fail (EPHY_IS_NODE (node));
- g_static_rw_lock_writer_lock (node->lock);
- g_static_rw_lock_writer_lock (child->lock);
-
real_remove_child (node, child, TRUE, TRUE);
-
- g_static_rw_lock_writer_unlock (node->lock);
- g_static_rw_lock_writer_unlock (child->lock);
-
- unlock_gdk ();
}
gboolean
@@ -1068,15 +875,9 @@ ephy_node_has_child (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- g_static_rw_lock_reader_lock (node->lock);
- g_static_rw_lock_reader_lock (child->lock);
-
ret = (g_hash_table_lookup (child->parents,
GINT_TO_POINTER (node->id)) != NULL);
- g_static_rw_lock_reader_unlock (node->lock);
- g_static_rw_lock_reader_unlock (child->lock);
-
return ret;
}
@@ -1108,10 +909,6 @@ ephy_node_sort_children (EphyNode *node,
g_return_if_fail (EPHY_IS_NODE (node));
g_return_if_fail (compare_func != NULL);
- lock_gdk ();
-
- g_static_rw_lock_writer_lock (node->lock);
-
newkids = g_ptr_array_new ();
g_ptr_array_set_size (newkids, node->children->len);
@@ -1141,15 +938,9 @@ ephy_node_sort_children (EphyNode *node,
g_ptr_array_free (node->children, FALSE);
node->children = newkids;
- write_lock_to_read_lock (node);
-
ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
g_free (new_order);
-
- g_static_rw_lock_reader_unlock (node->lock);
-
- unlock_gdk ();
}
void
@@ -1162,10 +953,6 @@ ephy_node_reorder_children (EphyNode *node,
g_return_if_fail (EPHY_IS_NODE (node));
g_return_if_fail (new_order != NULL);
- lock_gdk ();
-
- g_static_rw_lock_writer_lock (node->lock);
-
newkids = g_ptr_array_new ();
g_ptr_array_set_size (newkids, node->children->len);
@@ -1185,13 +972,7 @@ ephy_node_reorder_children (EphyNode *node,
g_ptr_array_free (node->children, FALSE);
node->children = newkids;
- write_lock_to_read_lock (node);
-
ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
-
- g_static_rw_lock_reader_unlock (node->lock);
-
- unlock_gdk ();
}
GPtrArray *
@@ -1199,8 +980,6 @@ ephy_node_get_children (EphyNode *node)
{
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- g_static_rw_lock_reader_lock (node->lock);
-
return node->children;
}
@@ -1211,12 +990,8 @@ ephy_node_get_n_children (EphyNode *node)
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_static_rw_lock_reader_lock (node->lock);
-
ret = node->children->len;
- g_static_rw_lock_reader_unlock (node->lock);
-
return ret;
}
@@ -1229,16 +1004,12 @@ ephy_node_get_nth_child (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
g_return_val_if_fail (n >= 0, NULL);
- g_static_rw_lock_reader_lock (node->lock);
-
if (n < node->children->len) {
ret = g_ptr_array_index (node->children, n);
} else {
ret = NULL;
}
- g_static_rw_lock_reader_unlock (node->lock);
-
return ret;
}
@@ -1267,14 +1038,8 @@ ephy_node_get_child_index (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), -1);
g_return_val_if_fail (EPHY_IS_NODE (child), -1);
- g_static_rw_lock_reader_lock (node->lock);
- g_static_rw_lock_reader_lock (child->lock);
-
ret = ephy_node_real_get_child_index (node, child);
- g_static_rw_lock_reader_unlock (node->lock);
- g_static_rw_lock_reader_unlock (child->lock);
-
return ret;
}
@@ -1288,9 +1053,6 @@ ephy_node_get_next_child (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- g_static_rw_lock_reader_lock (node->lock);
- g_static_rw_lock_reader_lock (child->lock);
-
idx = get_child_index_real (node, child);
if ((idx + 1) < node->children->len) {
@@ -1299,9 +1061,6 @@ ephy_node_get_next_child (EphyNode *node,
ret = NULL;
}
- g_static_rw_lock_reader_unlock (node->lock);
- g_static_rw_lock_reader_unlock (child->lock);
-
return ret;
}
@@ -1315,9 +1074,6 @@ ephy_node_get_previous_child (EphyNode *node,
g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- g_static_rw_lock_reader_lock (node->lock);
- g_static_rw_lock_reader_lock (child->lock);
-
idx = get_child_index_real (node, child);
if ((idx - 1) >= 0) {
@@ -1326,9 +1082,6 @@ ephy_node_get_previous_child (EphyNode *node,
ret = NULL;
}
- g_static_rw_lock_reader_unlock (node->lock);
- g_static_rw_lock_reader_unlock (child->lock);
-
return ret;
}