diff options
author | Alexander Larsson <alexl@src.gnome.org> | 2007-09-13 15:08:01 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2007-09-13 15:08:01 +0000 |
commit | 44dee05e4ddd619343c2e86501cf1021a5929e76 (patch) | |
tree | 0d7799620d4f9604b6b659d50cce5c8203850525 /daemon/gvfsjobenumerate.c | |
parent | b4e21e0a4c3955c0f3c3290550c26fddf51516bb (diff) | |
download | gvfs-44dee05e4ddd619343c2e86501cf1021a5929e76.tar.gz |
Better batching of file infos when enumerating files
Original git commit by Alexander Larsson <alexl@redhat.com> at 1189509721 +0200
svn path=/trunk/; revision=921
Diffstat (limited to 'daemon/gvfsjobenumerate.c')
-rw-r--r-- | daemon/gvfsjobenumerate.c | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/daemon/gvfsjobenumerate.c b/daemon/gvfsjobenumerate.c index d0496972..d30971bf 100644 --- a/daemon/gvfsjobenumerate.c +++ b/daemon/gvfsjobenumerate.c @@ -101,57 +101,67 @@ g_vfs_job_enumerate_new (DBusConnection *connection, return G_VFS_JOB (job); } -void -g_vfs_job_enumerate_add_infos (GVfsJobEnumerate *job, - GList *infos) +static void +send_infos (GVfsJobEnumerate *job) { - DBusMessage *message, *orig_message; - DBusMessageIter iter, array_iter; - int num; - GFileInfo *info; - - restart: - - orig_message = g_vfs_job_dbus_get_message (G_VFS_JOB_DBUS (job)); + if (!dbus_message_iter_close_container (&job->building_iter, &job->building_array_iter)) + _g_dbus_oom (); - message = dbus_message_new_method_call (dbus_message_get_sender (orig_message), - job->object_path, - G_VFS_DBUS_ENUMERATOR_INTERFACE, - G_VFS_DBUS_ENUMERATOR_OP_GOT_INFO); - dbus_message_set_no_reply (message, TRUE); - - dbus_message_iter_init_append (message, &iter); + dbus_connection_send (g_vfs_job_dbus_get_connection (G_VFS_JOB_DBUS (job)), + job->building_infos, NULL); + dbus_message_unref (job->building_infos); + job->building_infos = NULL; + job->n_building_infos = 0; +} - if (!dbus_message_iter_open_container (&iter, - DBUS_TYPE_ARRAY, - G_FILE_INFO_TYPE_AS_STRING, - &array_iter)) - _g_dbus_oom (); +void +g_vfs_job_enumerate_add_info (GVfsJobEnumerate *job, + GFileInfo *info) +{ + DBusMessage *message, *orig_message; - num = 0; - while (infos != NULL) + if (job->building_infos == NULL) { - info = infos->data; + orig_message = g_vfs_job_dbus_get_message (G_VFS_JOB_DBUS (job)); - g_file_info_set_attribute_mask (info, job->attribute_matcher); + message = dbus_message_new_method_call (dbus_message_get_sender (orig_message), + job->object_path, + G_VFS_DBUS_ENUMERATOR_INTERFACE, + G_VFS_DBUS_ENUMERATOR_OP_GOT_INFO); + dbus_message_set_no_reply (message, TRUE); - _g_dbus_append_file_info (&array_iter, - info); + dbus_message_iter_init_append (message, &job->building_iter); - infos = infos->next; - if (++num > 100) - break; + if (!dbus_message_iter_open_container (&job->building_iter, + DBUS_TYPE_ARRAY, + G_FILE_INFO_TYPE_AS_STRING, + &job->building_array_iter)) + _g_dbus_oom (); + + job->building_infos = message; + job->n_building_infos = 0; } - if (!dbus_message_iter_close_container (&iter, &array_iter)) - _g_dbus_oom (); - - dbus_connection_send (g_vfs_job_dbus_get_connection (G_VFS_JOB_DBUS (job)), - message, NULL); - dbus_message_unref (message); + g_file_info_set_attribute_mask (info, job->attribute_matcher); + _g_dbus_append_file_info (&job->building_array_iter, info); + job->n_building_infos++; - if (infos != NULL) - goto restart; + if (job->n_building_infos == 50) + send_infos (job); +} + +void +g_vfs_job_enumerate_add_infos (GVfsJobEnumerate *job, + GList *infos) +{ + GList *l; + GFileInfo *info; + + for (l = infos; l != NULL; l = l->next) + { + info = l->data; + g_vfs_job_enumerate_add_info (job, info); + } } void @@ -161,6 +171,9 @@ g_vfs_job_enumerate_done (GVfsJobEnumerate *job) g_assert (!G_VFS_JOB (job)->failed); + if (job->building_infos != NULL) + send_infos (job); + orig_message = g_vfs_job_dbus_get_message (G_VFS_JOB_DBUS (job)); message = dbus_message_new_method_call (dbus_message_get_sender (orig_message), |