struct _GOutputStreamPrivate {
guint closed : 1;
guint pending : 1;
+ guint closing : 1;
GAsyncReadyCallback outstanding_callback;
};
if (!g_output_stream_set_pending (stream, error))
return FALSE;
+ stream->priv->closing = TRUE;
+
if (cancellable)
g_cancellable_push_current (cancellable);
if (cancellable)
g_cancellable_pop_current (cancellable);
-
+
+ stream->priv->closing = FALSE;
stream->priv->closed = TRUE;
g_output_stream_clear_pending (stream);
{
GOutputStream *stream = G_OUTPUT_STREAM (source_object);
+ stream->priv->closing = FALSE;
stream->priv->closed = TRUE;
g_output_stream_clear_pending (stream);
if (stream->priv->outstanding_callback)
}
class = G_OUTPUT_STREAM_GET_CLASS (stream);
+ stream->priv->closing = TRUE;
stream->priv->outstanding_callback = callback;
g_object_ref (stream);
class->close_async (stream, io_priority, cancellable,
}
/**
+ * g_output_stream_is_closing:
+ * @stream: a #GOutputStream.
+ *
+ * Checks if an output stream is being closed. This can be
+ * used inside e.g. a flush implementation to see if the
+ * flush (or other i/o operation) is called from within
+ * the closing operation.
+ *
+ * Returns: %TRUE if @stream is being closed. %FALSE otherwise.
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_output_stream_is_closing (GOutputStream *stream)
+{
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), TRUE);
+
+ return stream->priv->closing;
+}
+
+/**
* g_output_stream_has_pending:
* @stream: a #GOutputStream.
*