equal
deleted
inserted
replaced
136 throw new IllegalArgumentException("Negative timeout value"); |
136 throw new IllegalArgumentException("Negative timeout value"); |
137 } |
137 } |
138 synchronized (lock) { |
138 synchronized (lock) { |
139 Reference<? extends T> r = reallyPoll(); |
139 Reference<? extends T> r = reallyPoll(); |
140 if (r != null) return r; |
140 if (r != null) return r; |
|
141 long start = (timeout == 0) ? 0 : System.nanoTime(); |
141 for (;;) { |
142 for (;;) { |
142 lock.wait(timeout); |
143 lock.wait(timeout); |
143 r = reallyPoll(); |
144 r = reallyPoll(); |
144 if (r != null) return r; |
145 if (r != null) return r; |
145 if (timeout != 0) return null; |
146 if (timeout != 0) { |
|
147 long end = System.nanoTime(); |
|
148 timeout -= (end - start) / 1000_000; |
|
149 if (timeout <= 0) return null; |
|
150 start = end; |
|
151 } |
146 } |
152 } |
147 } |
153 } |
148 } |
154 } |
149 |
155 |
150 /** |
156 /** |