2 * Copyright 2015-present Open Networking Foundation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package io.atomix.utils.concurrent;
18 import java.util.List;
21 * Abstraction of an accumulator capable of collecting items and at some
22 * point in time triggers processing of all previously accumulated items.
24 * @param <T> item type
26 public interface Accumulator<T> {
29 * Adds an item to the current batch. This operation may, or may not
30 * trigger processing of the current batch of items.
32 * @param item item to be added to the current batch
37 * Processes the specified list of accumulated items.
39 * @param items list of accumulated items
41 void processItems(List<T> items);
44 * Indicates whether the accumulator is ready to process items.
46 * @return true if ready to process