Coverage Summary for Class: ListeningScheduledExecutorService (com.google.common.util.concurrent)

Class Class, % Method, % Line, %
ListeningScheduledExecutorService 0% (0/1) 0% (0/4) 0% (0/6)


1 /* 2  * Copyright (C) 2011 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the License 10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11  * or implied. See the License for the specific language governing permissions and limitations under 12  * the License. 13  */ 14  15 package com.google.common.util.concurrent; 16  17 import static com.google.common.util.concurrent.Internal.toNanosSaturated; 18  19 import com.google.common.annotations.GwtIncompatible; 20 import java.time.Duration; 21 import java.util.concurrent.Callable; 22 import java.util.concurrent.ScheduledExecutorService; 23 import java.util.concurrent.TimeUnit; 24 import org.checkerframework.checker.nullness.qual.Nullable; 25  26 /** 27  * A {@link ScheduledExecutorService} that returns {@link ListenableFuture} instances from its 28  * {@code ExecutorService} methods. To create an instance from an existing {@link 29  * ScheduledExecutorService}, call {@link 30  * MoreExecutors#listeningDecorator(ScheduledExecutorService)}. 31  * 32  * @author Chris Povirk 33  * @since 10.0 34  */ 35 @GwtIncompatible 36 @ElementTypesAreNonnullByDefault 37 public interface ListeningScheduledExecutorService 38  extends ScheduledExecutorService, ListeningExecutorService { 39  40  /** @since 15.0 (previously returned ScheduledFuture) */ 41  @Override 42  ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); 43  44  /** 45  * Duration-based overload of {@link #schedule(Runnable, long, TimeUnit)}. 46  * 47  * @since 29.0 48  */ 49  default ListenableScheduledFuture<?> schedule(Runnable command, Duration delay) { 50  return schedule(command, toNanosSaturated(delay), TimeUnit.NANOSECONDS); 51  } 52  53  /** @since 15.0 (previously returned ScheduledFuture) */ 54  @Override 55  <V extends @Nullable Object> ListenableScheduledFuture<V> schedule( 56  Callable<V> callable, long delay, TimeUnit unit); 57  58  /** 59  * Duration-based overload of {@link #schedule(Callable, long, TimeUnit)}. 60  * 61  * @since 29.0 62  */ 63  default <V extends @Nullable Object> ListenableScheduledFuture<V> schedule( 64  Callable<V> callable, Duration delay) { 65  return schedule(callable, toNanosSaturated(delay), TimeUnit.NANOSECONDS); 66  } 67  68  /** @since 15.0 (previously returned ScheduledFuture) */ 69  @Override 70  ListenableScheduledFuture<?> scheduleAtFixedRate( 71  Runnable command, long initialDelay, long period, TimeUnit unit); 72  73  /** 74  * Duration-based overload of {@link #scheduleAtFixedRate(Runnable, long, long, TimeUnit)}. 75  * 76  * @since 29.0 77  */ 78  default ListenableScheduledFuture<?> scheduleAtFixedRate( 79  Runnable command, Duration initialDelay, Duration period) { 80  return scheduleAtFixedRate( 81  command, toNanosSaturated(initialDelay), toNanosSaturated(period), TimeUnit.NANOSECONDS); 82  } 83  84  /** @since 15.0 (previously returned ScheduledFuture) */ 85  @Override 86  ListenableScheduledFuture<?> scheduleWithFixedDelay( 87  Runnable command, long initialDelay, long delay, TimeUnit unit); 88  89  /** 90  * Duration-based overload of {@link #scheduleWithFixedDelay(Runnable, long, long, TimeUnit)}. 91  * 92  * @since 29.0 93  */ 94  default ListenableScheduledFuture<?> scheduleWithFixedDelay( 95  Runnable command, Duration initialDelay, Duration delay) { 96  return scheduleWithFixedDelay( 97  command, toNanosSaturated(initialDelay), toNanosSaturated(delay), TimeUnit.NANOSECONDS); 98  } 99 }