FakeTimeLimiter.java revision 1d580d0f6ee4f21eb309ba7b509d2c6d671c4044
1/*
2 * Copyright (C) 2006 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.common.util.concurrent;
18
19import com.google.common.annotations.Beta;
20
21import java.util.concurrent.Callable;
22import java.util.concurrent.TimeUnit;
23
24/**
25 * A TimeLimiter implementation which actually does not attempt to limit time
26 * at all.  This may be desirable to use in some unit tests.  More importantly,
27 * attempting to debug a call which is time-limited would be extremely annoying,
28 * so this gives you a time-limiter you can easily swap in for your real
29 * time-limiter while you're debugging.
30 *
31 * @author Kevin Bourrillion
32 * @since 1.0
33 */
34@Beta
35public final class FakeTimeLimiter implements TimeLimiter {
36  @Override
37  public <T> T newProxy(T target, Class<T> interfaceType, long timeoutDuration,
38      TimeUnit timeoutUnit) {
39    return target; // ha ha
40  }
41
42  @Override
43  public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration,
44      TimeUnit timeoutUnit, boolean amInterruptible) throws Exception {
45    return callable.call(); // fooled you
46  }
47}
48