d79a038395ab4c8391816b03ee7dcc5792346a37
[controller.git] / third-party / atomix / utils / src / main / java / io / atomix / utils / Managed.java
1 /*
2  * Copyright 2017-present Open Networking Foundation
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 package io.atomix.utils;
17
18 import java.util.concurrent.CompletableFuture;
19
20 /**
21  * Interface for types that can be asynchronously started and stopped.
22  *
23  * @param <T> managed type
24  */
25 public interface Managed<T> {
26
27   /**
28    * Starts the managed object.
29    *
30    * @return A completable future to be completed once the object has been started.
31    */
32   CompletableFuture<T> start();
33
34   /**
35    * Returns a boolean value indicating whether the managed object is running.
36    *
37    * @return Indicates whether the managed object is running.
38    */
39   boolean isRunning();
40
41   /**
42    * Stops the managed object.
43    *
44    * @return A completable future to be completed once the object has been stopped.
45    */
46   CompletableFuture<Void> stop();
47
48 }