[gimp] app: add GimpAsync::waiting signal
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add GimpAsync::waiting signal
- Date: Mon, 19 Nov 2018 20:07:33 +0000 (UTC)
commit 965da12b350c0844395050a706efe98ee49decd4
Author: Ell <ell_se yahoo com>
Date: Mon Nov 19 11:44:59 2018 -0500
app: add GimpAsync::waiting signal
... which is emitted when the async is being waited-upon, blocking
execution.
app/core/gimpasync.c | 43 ++++++++++++++++++++++++++++++++++++-------
app/core/gimpasync.h | 3 +++
2 files changed, 39 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpasync.c b/app/core/gimpasync.c
index 59a81ca99c..b1f3e932b7 100644
--- a/app/core/gimpasync.c
+++ b/app/core/gimpasync.c
@@ -27,6 +27,7 @@
#include "gimpasync.h"
#include "gimpcancelable.h"
+#include "gimpmarshal.h"
#include "gimpwaitable.h"
@@ -60,6 +61,13 @@
/* #define TIME_ASYNC_OPS */
+enum
+{
+ WAITING,
+ LAST_SIGNAL
+};
+
+
typedef struct _GimpAsyncCallbackInfo GimpAsyncCallbackInfo;
@@ -122,6 +130,8 @@ G_DEFINE_TYPE_WITH_CODE (GimpAsync, gimp_async, G_TYPE_OBJECT,
#define parent_class gimp_async_parent_class
+static guint async_signals[LAST_SIGNAL] = { 0 };
+
/* local variables */
@@ -136,6 +146,15 @@ gimp_async_class_init (GimpAsyncClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ async_signals[WAITING] =
+ g_signal_new ("waiting",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpAsyncClass, waiting),
+ NULL, NULL,
+ gimp_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
object_class->finalize = gimp_async_finalize;
}
@@ -209,8 +228,13 @@ gimp_async_wait (GimpWaitable *waitable)
g_mutex_lock (&async->priv->mutex);
- while (! async->priv->stopped)
- g_cond_wait (&async->priv->cond, &async->priv->mutex);
+ if (! async->priv->stopped)
+ {
+ g_signal_emit (async, async_signals[WAITING], 0);
+
+ while (! async->priv->stopped)
+ g_cond_wait (&async->priv->cond, &async->priv->mutex);
+ }
g_mutex_unlock (&async->priv->mutex);
@@ -259,14 +283,19 @@ gimp_async_wait_until (GimpWaitable *waitable,
g_mutex_lock (&async->priv->mutex);
- while (! async->priv->stopped)
+ if (! async->priv->stopped)
{
- if (! g_cond_wait_until (&async->priv->cond, &async->priv->mutex,
- end_time))
+ g_signal_emit (async, async_signals[WAITING], 0);
+
+ while (! async->priv->stopped)
{
- g_mutex_unlock (&async->priv->mutex);
+ if (! g_cond_wait_until (&async->priv->cond, &async->priv->mutex,
+ end_time))
+ {
+ g_mutex_unlock (&async->priv->mutex);
- return FALSE;
+ return FALSE;
+ }
}
}
diff --git a/app/core/gimpasync.h b/app/core/gimpasync.h
index 493f2c9c82..5a7510fb90 100644
--- a/app/core/gimpasync.h
+++ b/app/core/gimpasync.h
@@ -47,6 +47,9 @@ struct _GimpAsync
struct _GimpAsyncClass
{
GObjectClass parent_class;
+
+ /* signals */
+ void (* waiting) (GimpAsync *async);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]