summaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2017-11-10 13:06:51 +0000
committerArne Juul <arnej@yahoo-inc.com>2017-11-13 07:37:06 +0000
commit9e5aa2f7ab8d2af4832c032e1c28f84ede87b406 (patch)
tree669784ae32256e55d3b225caa2d49083d14c77ff /jdisc_core
parent7af8b3f0d2e4bbf5fcb6887220a3f15cbdefdf6a (diff)
add timeElapsed convenience method
* also, fix some misleading comments
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/Request.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
index 489a4c3dc10..7a76c588fb4 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
@@ -287,7 +287,7 @@ public class Request extends AbstractResource {
}
/**
- * <p>Returns the allocated number of milliseconds that this Request is allowed to exist. If no timeout has been set
+ * <p>Returns the allocated number of time units that this Request is allowed to exist. If no timeout has been set
* for this Request, this method returns <em>null</em>.</p>
*
* @param unit The unit to return the timeout in.
@@ -306,7 +306,7 @@ public class Request extends AbstractResource {
* <em>null</em>.</p>
*
* @param unit The unit to return the time in.
- * @return The number of milliseconds left until this Request times out, or <em>null</em>.
+ * @return The number of time units left until this Request times out, or <em>null</em>.
*/
public Long timeRemaining(TimeUnit unit) {
if (timeout == null) {
@@ -316,6 +316,16 @@ public class Request extends AbstractResource {
}
/**
+ * <p>Returns the time that this Request has existed so far.
+ *
+ * @param unit The unit to return the time in.
+ * @return The number of time units elapsed since this Request was created.
+ */
+ public long timeElapsed(TimeUnit unit) {
+ return unit.convert(container().currentTimeMillis() - creationTime, TimeUnit.MILLISECONDS);
+ }
+
+ /**
* <p>Returns the time at which this Request was created. This is whatever value was returned by {@link
* Timer#currentTimeMillis()} when constructing this.</p>
*