mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
Add g_output_stream_is_closing
Need this to check how we're flushing when closing a converter output stream.
This commit is contained in:
parent
848e0bf760
commit
afe3324fca
@ -51,6 +51,7 @@ G_DEFINE_TYPE (GOutputStream, g_output_stream, G_TYPE_OBJECT);
|
||||
struct _GOutputStreamPrivate {
|
||||
guint closed : 1;
|
||||
guint pending : 1;
|
||||
guint closing : 1;
|
||||
GAsyncReadyCallback outstanding_callback;
|
||||
};
|
||||
|
||||
@ -520,6 +521,8 @@ g_output_stream_close (GOutputStream *stream,
|
||||
if (!g_output_stream_set_pending (stream, error))
|
||||
return FALSE;
|
||||
|
||||
stream->priv->closing = TRUE;
|
||||
|
||||
if (cancellable)
|
||||
g_cancellable_push_current (cancellable);
|
||||
|
||||
@ -545,7 +548,8 @@ g_output_stream_close (GOutputStream *stream,
|
||||
|
||||
if (cancellable)
|
||||
g_cancellable_pop_current (cancellable);
|
||||
|
||||
|
||||
stream->priv->closing = FALSE;
|
||||
stream->priv->closed = TRUE;
|
||||
g_output_stream_clear_pending (stream);
|
||||
|
||||
@ -572,6 +576,7 @@ async_ready_close_callback_wrapper (GObject *source_object,
|
||||
{
|
||||
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)
|
||||
@ -982,6 +987,7 @@ g_output_stream_close_async (GOutputStream *stream,
|
||||
}
|
||||
|
||||
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,
|
||||
@ -1041,6 +1047,27 @@ g_output_stream_is_closed (GOutputStream *stream)
|
||||
return stream->priv->closed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -195,6 +195,7 @@ gboolean g_output_stream_close_finish (GOutputStream *stream,
|
||||
GError **error);
|
||||
|
||||
gboolean g_output_stream_is_closed (GOutputStream *stream);
|
||||
gboolean g_output_stream_is_closing (GOutputStream *stream);
|
||||
gboolean g_output_stream_has_pending (GOutputStream *stream);
|
||||
gboolean g_output_stream_set_pending (GOutputStream *stream,
|
||||
GError **error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user