com.alibaba.middleware.ushura.poller.PowerOfTwoPoller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eas-sdk Show documentation
Show all versions of eas-sdk Show documentation
SDK for PAI-EAS online inference services
package com.alibaba.middleware.ushura.poller;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class PowerOfTwoPoller implements Poller{
private AtomicInteger index = new AtomicInteger(0);
private List items = new ArrayList();
public PowerOfTwoPoller(List items){
this.items = items;
}
public T next() {
return items.get(index.getAndIncrement() & items.size() - 1);
}
public Poller refresh(List items) {
return new PowerOfTwoPoller(items);
}
}