[rygel/rygel-0-28] rygel: Chage user config change event logic
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-28] rygel: Chage user config change event logic
- Date: Tue, 1 Mar 2016 20:20:15 +0000 (UTC)
commit cd08e15d2b884d3a56959641767c712faebeb109
Author: Jens Georg <mail jensge org>
Date: Fri Feb 26 20:44:48 2016 +0100
rygel: Chage user config change event logic
Instead of re-reading on every file event, either do it on "changes done" or
after 500ms with no file event.
Signed-off-by: Jens Georg <mail jensge org>
src/rygel/rygel-user-config.vala | 42 ++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 089177b..d94d9b5 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -61,6 +61,9 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
// Our singleton
private static UserConfig config;
+ private uint system_config_timer_id = 0;
+ private uint local_config_timer_id = 0;
+
private class ConfigPair {
public ConfigurationEntry entry;
public EntryType type;
@@ -724,7 +727,6 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
sys_key_file.load_from_file (system.get_path (),
KeyFileFlags.KEEP_COMMENTS |
KeyFileFlags.KEEP_TRANSLATIONS);
-
} catch (GLib.Error e) {}
this.compare_and_notify (this.key_file, sys_key_file);
@@ -737,7 +739,6 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
key_file.load_from_file (local.get_path (),
KeyFileFlags.KEEP_COMMENTS |
KeyFileFlags.KEEP_TRANSLATIONS);
-
} catch (GLib.Error e) {}
this.compare_and_notify (key_file, this.sys_key_file);
@@ -747,13 +748,46 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
File file,
File? other_file,
FileMonitorEvent event_type) {
- this.reload_compare_and_notify_system (file);
+ if (event_type == FileMonitorEvent.CHANGES_DONE_HINT) {
+ if (this.system_config_timer_id != 0) {
+ Source.remove (this.system_config_timer_id);
+ this.system_config_timer_id = 0;
+ }
+ this.reload_compare_and_notify_system (file);
+ } else {
+ if (this.system_config_timer_id != 0) {
+ Source.remove (this.system_config_timer_id);
+ }
+ this.system_config_timer_id = Timeout.add (500, () => {
+ this.system_config_timer_id = 0;
+ this.reload_compare_and_notify_system (file);
+
+ return false;
+ });
+ }
}
private void on_local_config_changed (FileMonitor monitor,
File file,
File? other_file,
FileMonitorEvent event_type) {
- this.reload_compare_and_notify_local (file);
+ if (event_type == FileMonitorEvent.CHANGES_DONE_HINT) {
+ if (this.local_config_timer_id != 0) {
+ Source.remove (this.local_config_timer_id);
+ this.local_config_timer_id = 0;
+ }
+ this.reload_compare_and_notify_local (file);
+ } else {
+ if (this.local_config_timer_id != 0) {
+ Source.remove (this.local_config_timer_id);
+ }
+
+ this.local_config_timer_id = Timeout.add (500, () => {
+ this.local_config_timer_id = 0;
+ this.reload_compare_and_notify_local (file);
+
+ return false;
+ });
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]