summaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java
Publish
Diffstat (limited to 'jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java b/jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java
new file mode 100644
index 00000000000..4bca8136b8f
--- /dev/null
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/TimeoutManager.java
@@ -0,0 +1,40 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.jdisc;
+
+import com.yahoo.jdisc.handler.RequestHandler;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * <p>This interface provides a callback for when the {@link Request#setTimeout(long, TimeUnit)} is invoked. If no such
+ * handler is registered at the time where the target {@link RequestHandler} is called, the default timeout manager will
+ * be injected.</p>
+ *
+ * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
+ */
+public interface TimeoutManager {
+
+ /**
+ * Schedule timeout management for a request.
+ * This is called by a request whenever {@link Request#setTimeout(long, TimeUnit)} is invoked;
+ * this may be called multiple times for the same {@link Request}.
+ *
+ * @param request the request whose timeout to schedule
+ */
+ public void scheduleTimeout(Request request);
+
+ /**
+ * Unschedule timeout management for a previously scheduled request.
+ * This is called whenever a request is cancelled, and the purpose is to free up
+ * resources taken by the implementation of this associated with the request.
+ * <p>
+ * This is only called once for a request, and only after at least one scheduleTimeout call.
+ * <p>
+ * The default implementation of this does nothing.
+ *
+ * @param request the previously scheduled timeout
+ */
+ default public void unscheduleTimeout(Request request) {
+ }
+
+}