Import atomix/{storage,utils}
[controller.git] / third-party / atomix / utils / src / main / java / io / atomix / utils / concurrent / Accumulator.java
1 /*
2  * Copyright 2015-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.concurrent;
17
18 import java.util.List;
19
20 /**
21  * Abstraction of an accumulator capable of collecting items and at some
22  * point in time triggers processing of all previously accumulated items.
23  *
24  * @param <T> item type
25  */
26 public interface Accumulator<T> {
27
28   /**
29    * Adds an item to the current batch. This operation may, or may not
30    * trigger processing of the current batch of items.
31    *
32    * @param item item to be added to the current batch
33    */
34   void add(T item);
35
36   /**
37    * Processes the specified list of accumulated items.
38    *
39    * @param items list of accumulated items
40    */
41   void processItems(List<T> items);
42
43   /**
44    * Indicates whether the accumulator is ready to process items.
45    *
46    * @return true if ready to process
47    */
48   boolean isReady();
49 }