annotate src/org/eclipse/jetty/util/thread/Timeout.java @ 941:c948f674a2d5

simplify Timeout
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Oct 2016 00:34:19 -0600
parents 8e9db0bbf4f9
children c157a786ed0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.util.thread;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
21 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
22 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 /** Timeout queue.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 * This class implements a timeout queue for timers that are at least as likely to be cancelled as they are to expire.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 * Unlike the util timeout class, the duration of the timeouts is shared by all scheduled tasks and if the duration
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 * is changed, this affects all scheduled tasks.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 * The nested class Task should be extended by users of this class to obtain call back notification of
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 * expires.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 public class Timeout
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 {
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
36 private static final Logger LOG = LoggerFactory.getLogger(Timeout.class);
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
37 private Object _lock;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
38 private long _duration;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
39 private volatile long _now=System.currentTimeMillis();
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
40 private Task _head=new Task();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
42 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
43 public Timeout(Object lock)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
44 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
45 _lock=lock;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
46 _head._timeout=this;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
47 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
49 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
50 /**
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
51 * @return Returns the duration.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
52 */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
53 public long getDuration()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
54 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
55 return _duration;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
56 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
58 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
59 /**
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
60 * @param duration The duration to set.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
61 */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 public void setDuration(long duration)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
63 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
64 _duration = duration;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
65 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 public long setNow()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 return _now=System.currentTimeMillis();
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
72
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 public long getNow()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
76 return _now;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
79 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
80 public void setNow(long now)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
81 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 _now=now;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
83 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
84
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 /** Get an expired tasks.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 * This is called instead of {@link #tick()} to obtain the next
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 * expired Task, but without calling it's {@link Task#expire()} or
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
89 * {@link Task#expired()} methods.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 *
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 * @return the next expired task or null.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 */
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
93
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 public Task expired()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
95 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 synchronized (_lock)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 long _expiry = _now-_duration;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 if (_head._next!=_head)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
101 Task task = _head._next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 if (task._timestamp>_expiry)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 return null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
104
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 task.unlink();
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 task._expired=true;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 return task;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 return null;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
112
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 public void cancelAll()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 synchronized (_lock)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
117 _head._next=_head._prev=_head;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
118 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
120
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 public long getTimeToNext()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 synchronized (_lock)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 if (_head._next==_head)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 return -1;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 long to_next = _duration+_head._next._timestamp-_now;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 return to_next<0?0:to_next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
131
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
132 @Override
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 public String toString()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
134 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
135 StringBuffer buf = new StringBuffer();
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 buf.append(super.toString());
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 Task task = _head._next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 while (task!=_head)
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 buf.append("-->");
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 buf.append(task);
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 task=task._next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
145
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
146 return buf.toString();
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
147 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
148
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 /* ------------------------------------------------------------ */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 /** Task.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 * The base class for scheduled timeouts. This class should be
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 * extended to implement the expire() method, which is called if the
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 * timeout expires.
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 *
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 *
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 *
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 */
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 public static class Task
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 Task _next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 Task _prev;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
165 Timeout _timeout;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
166 long _timestamp=0;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
167 boolean _expired=false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
168
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 protected Task()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
171 _next=_prev=this;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
173
941
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 private void unlink()
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
175 {
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 _next._prev=_prev;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
177 _prev._next=_next;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
178 _next=_prev=this;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
179 _expired=false;
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
180 }
c948f674a2d5 simplify Timeout
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
181 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
182
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
183 }