[folks] bluez: Allow persona store update poll frequency to be modified
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] bluez: Allow persona store update poll frequency to be modified
- Date: Sun, 16 Feb 2014 23:54:43 +0000 (UTC)
commit f36c4b74355132bb6c46aa7bf06a2f2d7bfbefbf
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Nov 15 11:29:02 2013 +0000
bluez: Allow persona store update poll frequency to be modified
For unit testing, it’s nice to not have to wait 5s between polled
updates of the BlueZ persona store. Add a new environment variable,
FOLKS_BLUEZ_TIMEOUT_DIVISOR, which allows the poll frequency to be
divided by the specified amount.
This should speed up the unit tests 100×.
https://bugzilla.gnome.org/show_bug.cgi?id=712274
backends/bluez/bluez-persona-store.vala | 32 ++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/backends/bluez/bluez-persona-store.vala b/backends/bluez/bluez-persona-store.vala
index af341af..cad039a 100644
--- a/backends/bluez/bluez-persona-store.vala
+++ b/backends/bluez/bluez-persona-store.vala
@@ -935,7 +935,8 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
PersonaStore._MAX_CONSECUTIVE_FAILURES)
return;
- /* Calculate the timeout. */
+ /* Calculate the timeout (in milliseconds). If no divisor is applied, the
+ * timeout should always be a whole number of seconds. */
var timeout =
uint.min (PersonaStore._TIMEOUT_MIN +
(uint) Math.pow (PersonaStore._TIMEOUT_BASE,
@@ -943,9 +944,23 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
PersonaStore._TIMEOUT_MAX);
this._update_contacts_n++;
+ timeout *= 1000; /* convert from seconds to milliseconds */
+
+ /* Allow the timeout to be tweaked for testing. */
+ var divisor_str =
+ Environment.get_variable ("FOLKS_BLUEZ_TIMEOUT_DIVISOR");
+ if (divisor_str != null)
+ {
+ uint64 divisor;
+ if (uint64.try_parse (divisor_str, out divisor) == true)
+ timeout /= (uint) divisor;
+ }
+
/* Schedule the update. */
- this._update_contacts_id = Timeout.add_seconds (timeout, () =>
+ SourceFunc fn = () =>
{
+ debug ("Scheduled update firing for BlueZ store ‘%s’.", this.id);
+
/* Acknowledge the source has fired. */
this._update_contacts_id = 0;
@@ -976,7 +991,18 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
});
return false;
- });
+ };
+
+ if (timeout % 1000 == 0)
+ {
+ this._update_contacts_id =
+ Timeout.add_seconds (timeout / 1000, (owned) fn);
+ }
+ else
+ {
+ this._update_contacts_id =
+ Timeout.add (timeout, (owned) fn);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]