[tracker/dbus-fd-experiment-gio: 41/41] client: use buffered streams
- From: Adrien Bustany <abustany src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dbus-fd-experiment-gio: 41/41] client: use buffered streams
- Date: Thu, 10 Jun 2010 22:55:40 +0000 (UTC)
commit fe6e3d00f445c9c988344e12632a5a05d82d3d27
Author: Adrien Bustany <abustany gnome org>
Date: Thu Jun 10 18:51:39 2010 -0400
client: use buffered streams
src/libtracker-client/tracker.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 69b4857..803a3dd 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -505,6 +505,7 @@ fast_async_callback_iterator (GObject *source_object,
GError *error = NULL;
FastAsyncData *data = user_data;
TrackerResultIterator *iterator = data->result_iterator;
+ GInputStream *base_input_stream;
dbus_error_init (&dbus_error);
@@ -514,7 +515,9 @@ fast_async_callback_iterator (GObject *source_object,
iterator->buffer = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->output_stream));
+ base_input_stream = g_filter_input_stream_get_base_stream (G_FILTER_INPUT_STREAM (data->input_stream));
g_object_unref (data->input_stream);
+ g_object_unref (base_input_stream);
g_object_unref (data->output_stream);
if (inner_error) {
@@ -942,6 +945,7 @@ sparql_update_fast (TrackerClient *client,
DBusError dbus_error;
int pipefd[2];
GOutputStream *output_stream;
+ GOutputStream *buffered_output_stream;
GDataOutputStream *data_output_stream;
GError *inner_error = NULL;
@@ -998,7 +1002,9 @@ sparql_update_fast (TrackerClient *client,
}
output_stream = g_unix_output_stream_new (pipefd[1], TRUE);
- data_output_stream = g_data_output_stream_new (output_stream);
+ buffered_output_stream = g_buffered_output_stream_new_sized (output_stream,
+ TRACKER_STEROIDS_BUFFER_SIZE);
+ data_output_stream = g_data_output_stream_new (buffered_output_stream);
g_data_output_stream_put_int32 (data_output_stream,
strlen (query),
@@ -1025,6 +1031,7 @@ sparql_update_fast (TrackerClient *client,
}
g_object_unref (data_output_stream);
+ g_object_unref (buffered_output_stream);
g_object_unref (output_stream);
dbus_pending_call_block (call);
@@ -1059,6 +1066,7 @@ sparql_update_fast_async (TrackerClient *client,
DBusError dbus_error;
int pipefd[2];
GOutputStream *output_stream;
+ GOutputStream *buffered_output_stream;
GDataOutputStream *data_output_stream;
GError *inner_error = NULL;
@@ -1112,6 +1120,8 @@ sparql_update_fast_async (TrackerClient *client,
}
output_stream = g_unix_output_stream_new (pipefd[1], TRUE);
+ buffered_output_stream = g_buffered_output_stream_new_sized (output_stream,
+ TRACKER_STEROIDS_BUFFER_SIZE);
data_output_stream = g_data_output_stream_new (output_stream);
g_data_output_stream_put_int32 (data_output_stream,
@@ -1139,6 +1149,7 @@ sparql_update_fast_async (TrackerClient *client,
}
g_object_unref (data_output_stream);
+ g_object_unref (buffered_output_stream);
g_object_unref (output_stream);
dbus_pending_call_set_notify (call, sparql_update_fast_callback, data, NULL);
@@ -1598,6 +1609,7 @@ tracker_resources_sparql_query_iterate (TrackerClient *client,
TrackerResultIterator *iterator;
int pipefd[2];
GInputStream *input_stream;
+ GInputStream *buffered_input_stream;
GOutputStream *iterator_output_stream;
GError *inner_error = NULL;
@@ -1644,14 +1656,17 @@ tracker_resources_sparql_query_iterate (TrackerClient *client,
iterator = g_slice_new0 (TrackerResultIterator);
input_stream = g_unix_input_stream_new (pipefd[0], TRUE);
+ buffered_input_stream = g_buffered_input_stream_new_sized (input_stream,
+ TRACKER_STEROIDS_BUFFER_SIZE);
iterator_output_stream = g_memory_output_stream_new (NULL, 0, g_realloc, NULL);
iterator->buffer_size = g_output_stream_splice (iterator_output_stream,
- input_stream,
+ buffered_input_stream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
NULL,
&inner_error);
iterator->buffer = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (iterator_output_stream));
+ g_object_unref (buffered_input_stream);
g_object_unref (input_stream);
g_object_unref (iterator_output_stream);
@@ -2235,6 +2250,7 @@ tracker_resources_sparql_query_iterate_async (TrackerClient *client,
TrackerResultIterator *iterator;
int pipefd[2];
GInputStream *input_stream;
+ GInputStream *buffered_input_stream;
GOutputStream *iterator_output_stream;
FastAsyncData *async_data;
@@ -2277,17 +2293,19 @@ tracker_resources_sparql_query_iterate_async (TrackerClient *client,
iterator = g_slice_new0 (TrackerResultIterator);
input_stream = g_unix_input_stream_new (pipefd[0], TRUE);
+ buffered_input_stream = g_buffered_input_stream_new_sized (input_stream,
+ TRACKER_STEROIDS_BUFFER_SIZE);
iterator_output_stream = g_memory_output_stream_new (NULL, 0, g_realloc, NULL);
async_data->result_iterator = iterator;
- async_data->input_stream = input_stream;
+ async_data->input_stream = buffered_input_stream;
async_data->output_stream = iterator_output_stream;
async_data->dbus_call = call;
async_data->iterator_callback = callback;
async_data->user_data = user_data;
g_output_stream_splice_async (iterator_output_stream,
- input_stream,
+ buffered_input_stream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
0,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]