Class EventRateLimiter

  • All Implemented Interfaces:
    EventListener

    public class EventRateLimiter
    extends java.lang.Object
    implements EventListener
    EventRateLimiter that acts as an EventListener and forwards the received UpdateEvents to a secondary EventListener at a predefined maximum rate. This class may be useful in an UI contexts where the visualisation cannot be updated in time due to its numerical complexity, or for contexts where the numerical post-processing can be skipped or dropped if new UpdateEvents arrive.

    Basic usage:

     
      evtSource.addListener(new EventRateLimiter(evt -> {  ... do stuff with the event ... }, MAX_UPDATE_PERIOD));
      // or, more explicitly:
      evtSource.addListener(new EventRateLimiter(evt -> {  ... do stuff with the event ... }, MAX_UPDATE_PERIOD,
                  UpdateStrategy.INSTANTANEOUS_RATE));
     
     
    Author:
    rstein