org.cruxframework.crux.core.client.executor
Class ThrottleExecutor

java.lang.Object
  extended by org.cruxframework.crux.core.client.executor.ThrottleExecutor

public abstract class ThrottleExecutor
extends Object

Throttles a chain of incoming tasks in order to execute only some of them, ensuring that the max number of tasks executed per second is fixed.

Author:
Gesse Dafe

Constructor Summary
ThrottleExecutor(int ratio)
          Creates a executor capable of controlling the interval between the invocations to its action.
 
Method Summary
protected abstract  void doAction()
          Executes the desired action.
 void throttle()
          Throttles the invocations on the executor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThrottleExecutor

public ThrottleExecutor(int ratio)
Creates a executor capable of controlling the interval between the invocations to its action.

Parameters:
ratio - the interval between the invocations, in milliseconds
Method Detail

throttle

public void throttle()
Throttles the invocations on the executor


doAction

protected abstract void doAction()
Executes the desired action. The invocation ratio of this method is controlled by the ratio field of this instance.



Copyright © 2014. All rights reserved.