summaryrefslogtreecommitdiff
path: root/src/glibext/delayed.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-12-20 00:28:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-12-20 00:28:36 (GMT)
commit56deaf395c65658102ef0111cfc072d65335331a (patch)
treeba6d6fd0dbc781e9ad3b3cf6b2eb529a7d7a6aa3 /src/glibext/delayed.c
parentd9fdfcf887a7a596a68db2500bb5e4d0b692abb6 (diff)
Begun to clean the code by moving the disassembling process into disass/.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@202 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext/delayed.c')
-rw-r--r--src/glibext/delayed.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/glibext/delayed.c b/src/glibext/delayed.c
index 8f23538..92e167a 100644
--- a/src/glibext/delayed.c
+++ b/src/glibext/delayed.c
@@ -40,6 +40,12 @@ static void g_delayed_work_class_init(GDelayedWorkClass *);
/* Initialise une instance de travail différé. */
static void g_delayed_work_init(GDelayedWork *);
+/* Supprime toutes les références externes. */
+static void g_delayed_work_dispose(GDelayedWork *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_delayed_work_finalize(GDelayedWork *);
+
/* Mène l'opération programmée. */
static void g_delayed_work_process(GDelayedWork *, GtkExtStatusBar *);
@@ -155,6 +161,13 @@ G_DEFINE_TYPE(GDelayedWork, g_delayed_work, G_TYPE_OBJECT);
static void g_delayed_work_class_init(GDelayedWorkClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_delayed_work_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_delayed_work_finalize;
+
g_signal_new("work-completed",
G_TYPE_DELAYED_WORK,
G_SIGNAL_RUN_LAST,
@@ -180,6 +193,58 @@ static void g_delayed_work_class_init(GDelayedWorkClass *klass)
static void g_delayed_work_init(GDelayedWork *work)
{
+ work->completed = false;
+ work->mutex = g_mutex_new();
+ work->cond = g_cond_new();
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : work = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_delayed_work_dispose(GDelayedWork *work)
+{
+ gpointer obj_class; /* Classe parente */
+
+ g_mutex_free(work->mutex);
+ g_cond_free(work->cond);
+
+ obj_class = g_type_class_peek_parent(G_DELAYED_WORK_GET_CLASS(work));
+
+ //G_OBJECT_CLASS(obj_class)->dispose(G_OBJECT(work));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : work = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_delayed_work_finalize(GDelayedWork *work)
+{
+ gpointer obj_class; /* Classe parente */
+
+ obj_class = g_type_class_peek_parent(G_DELAYED_WORK_GET_CLASS(work));
+
+ //G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(work));
}
@@ -203,6 +268,37 @@ static void g_delayed_work_process(GDelayedWork *work, GtkExtStatusBar *statusba
g_signal_emit_by_name(work, "work-completed");
+ g_mutex_lock(work->mutex);
+
+ work->completed = true;
+
+ g_cond_signal(work->cond);
+ g_mutex_unlock(work->mutex);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : work = travail à surveiller. *
+* *
+* Description : Attend la fin de l'exécution d'une tâche donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_delayed_work_wait_for_completion(GDelayedWork *work)
+{
+ g_mutex_lock(work->mutex);
+
+ while (!work->completed)
+ g_cond_wait(work->cond, work->mutex);
+
+ g_mutex_unlock(work->mutex);
+
}