Add g_input_stream_read_all_async()

Add an asynchronous version of _read_all().

This API is not fully consistent with the normal expectations of a
non-asynchronous version.  Consistency between the sync and async version is
probably more important.

The API will still bind correctly, but access to all functionality will
not be available: specifically, in the case of an error, higher level
languages will be unable to determine how many bytes were successfully
read before the error.  Most users will probably not want to use this
information anyway, so this is OK -- and if they do need the
information, then they can just write the loop for themselves.

Heavily based on a patch from Ignacio Casal Quinteiro.

https://bugzilla.gnome.org/show_bug.cgi?id=737451
This commit is contained in:
Ryan Lortie
2014-09-29 11:40:46 -04:00
parent aabc3a41c3
commit 76b890d0f1
2 changed files with 194 additions and 0 deletions

View File

@@ -151,6 +151,21 @@ GLIB_AVAILABLE_IN_ALL
gssize g_input_stream_read_finish (GInputStream *stream,
GAsyncResult *result,
GError **error);
GLIB_AVAILABLE_IN_2_44
void g_input_stream_read_all_async (GInputStream *stream,
void *buffer,
gsize count,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GLIB_AVAILABLE_IN_2_44
gboolean g_input_stream_read_all_finish (GInputStream *stream,
GAsyncResult *result,
gsize *bytes_read,
GError **error);
GLIB_AVAILABLE_IN_2_34
void g_input_stream_read_bytes_async (GInputStream *stream,
gsize count,