org.omnaest.utils.operation.special
Class OperationBlockingToFastRepeatingExecutions<RESULT,PARAMETER>

java.lang.Object
  extended by org.omnaest.utils.operation.special.OperationBlockingToFastRepeatingExecutions<RESULT,PARAMETER>
Type Parameters:
RESULT -
PARAMETER -
All Implemented Interfaces:
Operation<RESULT,PARAMETER>

public class OperationBlockingToFastRepeatingExecutions<RESULT,PARAMETER>
extends Object
implements Operation<RESULT,PARAMETER>

Operation which will allow to execute the execute(Object) method only once within a given period of time. All faster reinvoked execute(Object) calls will result in an OperationBlockingToFastRepeatingExecutions.ToFastInvocationException.

Author:
Omnaest

Nested Class Summary
static class OperationBlockingToFastRepeatingExecutions.ToFastInvocationException
           
 
Field Summary
protected  long alreadyToleratedToFastInvocations
           
protected  DurationCapture durationCapture
           
protected  long forcedDurationAfterToFastInvocationInMilliseconds
           
protected  boolean lastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls
           
protected  int maximumNumberOfToleratedTooFastInvocations
           
protected  long minimalDurationBetweenExecutionInMilliseconds
           
protected  Operation<RESULT,PARAMETER> operation
           
 
Constructor Summary
OperationBlockingToFastRepeatingExecutions(Operation<RESULT,PARAMETER> operation, int maximumNumberOfToleratedTooFastInvocations, long minimalDurationBetweenExecutionInMilliseconds, long forcedDurationAfterToFastInvocationInMilliseconds)
           
OperationBlockingToFastRepeatingExecutions(Operation<RESULT,PARAMETER> operation, long minimalDurationBetweenExecutionInMilliseconds, long forcedDurationAfterToFastInvocationInMilliseconds)
           
 
Method Summary
 RESULT execute(PARAMETER parameter)
           
 boolean hasLastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls()
          Returns true if the next execute(Object) will be forced to wait for forcedDurationAfterToFastInvocationInMilliseconds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operation

protected Operation<RESULT,PARAMETER> operation

maximumNumberOfToleratedTooFastInvocations

protected int maximumNumberOfToleratedTooFastInvocations

minimalDurationBetweenExecutionInMilliseconds

protected long minimalDurationBetweenExecutionInMilliseconds

forcedDurationAfterToFastInvocationInMilliseconds

protected long forcedDurationAfterToFastInvocationInMilliseconds

lastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls

protected boolean lastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls

durationCapture

protected DurationCapture durationCapture

alreadyToleratedToFastInvocations

protected long alreadyToleratedToFastInvocations
Constructor Detail

OperationBlockingToFastRepeatingExecutions

public OperationBlockingToFastRepeatingExecutions(Operation<RESULT,PARAMETER> operation,
                                                  long minimalDurationBetweenExecutionInMilliseconds,
                                                  long forcedDurationAfterToFastInvocationInMilliseconds)
Parameters:
operation -
minimalDurationBetweenExecutionInMilliseconds -
forcedDurationAfterToFastInvocationInMilliseconds -

OperationBlockingToFastRepeatingExecutions

public OperationBlockingToFastRepeatingExecutions(Operation<RESULT,PARAMETER> operation,
                                                  int maximumNumberOfToleratedTooFastInvocations,
                                                  long minimalDurationBetweenExecutionInMilliseconds,
                                                  long forcedDurationAfterToFastInvocationInMilliseconds)
Parameters:
operation -
maximumNumberOfToleratedTooFastInvocations -
minimalDurationBetweenExecutionInMilliseconds -
forcedDurationAfterToFastInvocationInMilliseconds -
See Also:
OperationBlockingToFastRepeatingExecutions
Method Detail

execute

public RESULT execute(PARAMETER parameter)
Specified by:
execute in interface Operation<RESULT,PARAMETER>

hasLastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls

public boolean hasLastInvocationExceededMinimalDurationBetweenTwoExcecutionCalls()
Returns true if the next execute(Object) will be forced to wait for forcedDurationAfterToFastInvocationInMilliseconds

Returns:


Copyright © 2013. All Rights Reserved.