use of me.retrodaredevil.action.node.util.NanoTimeProvider in project solarthing by wildmountainfarms.
the class TimeoutActionNode method createAction.
@Override
public Action createAction(ActionEnvironment actionEnvironment) {
NanoTimeProviderEnvironment nanoTimeProviderEnvironment = actionEnvironment.getInjectEnvironment().get(NanoTimeProviderEnvironment.class);
NanoTimeProvider nanoTimeProvider = nanoTimeProviderEnvironment.getNanoTimeProvider();
return Actions.createDynamicActionRunner(() -> {
final Long lastFireNanos = this.lastFireNanos;
long nowNanos = nanoTimeProvider.getNanos();
if (lastFireNanos == null || nowNanos - lastFireNanos > timeoutNanos) {
this.lastFireNanos = nowNanos;
return actionNode.createAction(actionEnvironment);
}
return Actions.createRunOnce(() -> {
});
});
}
Aggregations