[libgames-support] Get rid of blocking I/O in save_score_to_file
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgames-support] Get rid of blocking I/O in save_score_to_file
- Date: Sun, 20 Sep 2015 22:55:30 +0000 (UTC)
commit 673fec980eac02f74995c2eaff762243c0fe6cbb
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Sep 20 17:51:33 2015 -0500
Get rid of blocking I/O in save_score_to_file
games/scores/context.vala | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/games/scores/context.vala b/games/scores/context.vala
index 425d9e1..6ddf96c 100644
--- a/games/scores/context.vala
+++ b/games/scores/context.vala
@@ -187,13 +187,11 @@ public class Context : Object
}
var file = File.new_for_path (Path.build_filename (user_score_dir, category.key));
+ var stream = file.append_to (FileCreateFlags.NONE);
+ var line = @"$(score.score) $(score.time) $(score.user)\n";
- // FIXME should not be doing sync I/O here
- var dos = new DataOutputStream (file.append_to (FileCreateFlags.NONE));
-
- dos.put_string (score.score.to_string () + " " +
- score.time.to_string () + " " +
- score.user + "\n");
+ // FIXME add cancellable parameter
+ yield stream.write_all_async (line.data, Priority.DEFAULT, null, null);
}
private void load_scores_from_files () throws Error
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]