[glib] streams: add private 'async close via threads' API
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] streams: add private 'async close via threads' API
- Date: Tue, 17 Feb 2015 21:31:55 +0000 (UTC)
commit cb40c553aefff522cf3c6ff8af783afa3e217649
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Jan 20 08:09:33 2015 -0500
streams: add private 'async close via threads' API
Add an internal helper to find out if close_async() is implemented via
threads using the default implementation in the base class.
We will use this to decide if we should do a 'pure async' close of a
GIOStream or not.
https://bugzilla.gnome.org/show_bug.cgi?id=741630
gio/ginputstream.c | 20 ++++++++++++++++++++
gio/gioprivate.h | 2 ++
gio/goutputstream.c | 19 +++++++++++++++++++
3 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/gio/ginputstream.c b/gio/ginputstream.c
index 16a03c0..8030256 100644
--- a/gio/ginputstream.c
+++ b/gio/ginputstream.c
@@ -1253,6 +1253,26 @@ g_input_stream_async_read_is_via_threads (GInputStream *stream)
g_pollable_input_stream_can_poll (G_POLLABLE_INPUT_STREAM (stream))));
}
+/*< internal >
+ * g_input_stream_async_close_is_via_threads:
+ * @stream: input stream
+ *
+ * Checks if an input stream's close_async function uses threads.
+ *
+ * Returns: %TRUE if @stream's close_async function uses threads.
+ **/
+gboolean
+g_input_stream_async_close_is_via_threads (GInputStream *stream)
+{
+ GInputStreamClass *class;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE);
+
+ class = G_INPUT_STREAM_GET_CLASS (stream);
+
+ return class->close_async == g_input_stream_real_close_async;
+}
+
/********************************************
* Default implementation of async ops *
********************************************/
diff --git a/gio/gioprivate.h b/gio/gioprivate.h
index 076259c..b3f65bf 100644
--- a/gio/gioprivate.h
+++ b/gio/gioprivate.h
@@ -27,7 +27,9 @@
G_BEGIN_DECLS
gboolean g_input_stream_async_read_is_via_threads (GInputStream *stream);
+gboolean g_input_stream_async_close_is_via_threads (GInputStream *stream);
gboolean g_output_stream_async_write_is_via_threads (GOutputStream *stream);
+gboolean g_output_stream_async_close_is_via_threads (GOutputStream *stream);
void g_socket_connection_set_cached_remote_address (GSocketConnection *connection,
GSocketAddress *address);
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index ea05b41..035465d 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -1705,6 +1705,25 @@ g_output_stream_async_write_is_via_threads (GOutputStream *stream)
g_pollable_output_stream_can_poll (G_POLLABLE_OUTPUT_STREAM (stream))));
}
+/*< internal >
+ * g_output_stream_async_close_is_via_threads:
+ * @stream: output stream
+ *
+ * Checks if an output stream's close_async function uses threads.
+ *
+ * Returns: %TRUE if @stream's close_async function uses threads.
+ **/
+gboolean
+g_output_stream_async_close_is_via_threads (GOutputStream *stream)
+{
+ GOutputStreamClass *class;
+
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
+
+ class = G_OUTPUT_STREAM_GET_CLASS (stream);
+
+ return class->close_async == g_output_stream_real_close_async;
+}
/********************************************
* Default implementation of async ops *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]