All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.edgar615.util.eventbus.BlockedEventHolder Maven / Gradle / Ivy

There is a newer version: 1.0.11
Show newest version
package com.github.edgar615.util.eventbus;

import com.github.edgar615.util.event.Event;

/**
 * Created by Edgar on 2016/7/8.
 *
 * @author Edgar  Date 2016/7/8
 */
class BlockedEventHolder {
  private final Event event;

  private final long maxExecTime;

  private boolean completed;

  private long completedOn;

  private long startedOn = System.currentTimeMillis();

  private BlockedEventHolder(Event event, long maxExecTime) {
    this.event = event;
    this.maxExecTime = maxExecTime;
  }

  static BlockedEventHolder create(Event event, long maxExecTime) {
    return new BlockedEventHolder(event, maxExecTime);
  }

  public long maxExecTime() {
    return maxExecTime;
  }

  public void completed() {
    this.completed = true;
    this.completedOn = System.currentTimeMillis();
  }

  public long duration() {
    return System.currentTimeMillis() - startedOn;
  }

  public Event event() {
    return event;
  }

  public boolean isCompleted() {
    return completed;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy