aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_time_lib.h
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2013-07-22 08:26:16 -0500
committerDavid Barksdale <amatus.amongus@gmail.com>2013-07-22 08:26:16 -0500
commit7450bd0b6c6c05ee6425e2c63e9b79beb94bfbfa (patch)
treedfde89b41437def7ce23af24db53a11a9b5f1075 /src/include/gnunet_time_lib.h
parent740b30688bd745a527f96f9116c19acb3480971a (diff)
Imported Upstream version 0.9.5aupstream
Diffstat (limited to 'src/include/gnunet_time_lib.h')
-rw-r--r--src/include/gnunet_time_lib.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index 35d180c..d131e4e 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -150,6 +150,22 @@ GNUNET_NETWORK_STRUCT_END
#define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever_ ()
+
+/**
+ * Threshold after which exponential backoff should not increase (15 m).
+ */
+#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
+
+
+/**
+ * Perform our standard exponential back-off calculation, starting at 1mst
+ * and then going by a factor of 2 up unto a maximum of 1s.
+ *
+ * @param r current backoff time, initially zero
+ */
+#define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min (GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2));
+
/**
* Return relative time of 0ms.
*/
@@ -441,18 +457,6 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a);
/**
- * Convert a relative time to a string.
- * NOT reentrant!
- *
- * @param time the time to print
- *
- * @return string form of the time (as milliseconds)
- */
-const char *
-GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time);
-
-
-/**
* Set the timestamp offset for this instance.
*
* @param offset the offset to skew the locale time by