java.util.concurrent.Delayed#getDelay ( )源码实例Demo

下面列出了java.util.concurrent.Delayed#getDelay ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: elasticactors   文件: ScheduledMessageImpl.java
@Override
public int compareTo(Delayed other) {
    if (other == this)
        return 0;
    long d = (getDelay(TimeUnit.MILLISECONDS) -
            other.getDelay(TimeUnit.MILLISECONDS));
    if(d != 0) {
        return (d < 0) ? -1 : 1;
    } else {
        // use the ordering of the id as well in case the other Delayed is a ScheduledMessage as well
        if(other instanceof ScheduledMessage) {
            return getId().compareTo(((ScheduledMessage)other).getId());
        } else {
            return 0;
        }
    }
}
 
源代码2 项目: nh-micro   文件: MicroDelayItem.java
public int compareTo(Delayed other) {
    if (other == this) // compare zero ONLY if same object
        return 0;
    if (other instanceof MicroDelayItem) {
    	MicroDelayItem x = (MicroDelayItem) other;
        long diff = time - x.time;
        if (diff < 0)
            return -1;
        else if (diff > 0)
            return 1;
        else if (sequenceNumber < x.sequenceNumber)
            return -1;
        else
            return 1;
    }
    long d = (getDelay(TimeUnit.NANOSECONDS) - other.getDelay(TimeUnit.NANOSECONDS));
    return (d == 0) ? 0 : ((d < 0) ? -1 : 1);
}
 
源代码3 项目: threadly   文件: TestDelayed.java
@Override
public int compareTo(Delayed o) {
  if (this == o) {
    return 0;
  } else if (o instanceof TestDelayed) {
    return (int)(delayInMs - ((TestDelayed)o).delayInMs);
  } else {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long otherDelay = o.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay == otherDelay) {
      return 0;
    } else if (thisDelay > otherDelay) {
      return 1;
    } else {
      return -1;
    }
  }
}
 
源代码4 项目: jstarcraft-core   文件: DelayLong.java
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
源代码5 项目: tracing-framework   文件: ThrottlingDelayQueue.java
@Override
public int compareTo(Delayed other) {
    if (other instanceof ThrottlingDelayQueue.TenantThrottler) {
        long onext = ((ThrottlingDelayQueue.TenantThrottler) other).next;
        if (next < onext)
            return -1;
        else if (next == onext)
            return 0;
        else
            return 1;
    } else {
        long odelay = other.getDelay(TimeUnit.NANOSECONDS);
        long tdelay = this.getDelay(TimeUnit.NANOSECONDS);
        if (tdelay < odelay)
            return -1;
        else if (tdelay == odelay)
            return 0;
        else
            return 1;
    }
}
 
源代码6 项目: RDFS   文件: GridmixJob.java
@Override
public int compareTo(Delayed other) {
  if (this == other) {
    return 0;
  }
  if (other instanceof GridmixJob) {
    final long otherNanos = ((GridmixJob)other).submissionTimeNanos;
    if (otherNanos < submissionTimeNanos) {
      return 1;
    }
    if (otherNanos > submissionTimeNanos) {
      return -1;
    }
    return id() - ((GridmixJob)other).id();
  }
  final long diff =
    getDelay(TimeUnit.NANOSECONDS) - other.getDelay(TimeUnit.NANOSECONDS);
  return 0 == diff ? 0 : (diff > 0 ? 1 : -1);
}
 
@Override
public int compareTo(Delayed other) {
    if (other == this) { // compare zero if same object
        return 0;
    }
    if (other instanceof ScheduledSQSFutureTask) {
        ScheduledSQSFutureTask<?> x = (ScheduledSQSFutureTask<?>)other;
        long diff = time - x.time;
        if (diff < 0) {
            return -1;
        } else if (diff > 0) {
            return 1;
        } else {
            return 0;
        }
    }
    long d = getDelay(TimeUnit.NANOSECONDS) -
            other.getDelay(TimeUnit.NANOSECONDS);
    return (d == 0) ? 0 : ((d < 0) ? -1 : 1);
}
 
源代码8 项目: xian   文件: OperationAndData.java
@Override
public int compareTo(Delayed o)
{
    if ( o == this )
    {
        return 0;
    }

    long diff = getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS);
    if ( diff == 0 )
    {
        if ( o instanceof OperationAndData )
        {
            diff = ordinal.get() - ((OperationAndData)o).ordinal.get();
        }
    }

    return (diff < 0) ? -1 : ((diff > 0) ? 1 : 0);
}
 
源代码9 项目: dhis2-core   文件: QueuedAudit.java
@Override
public int compareTo( Delayed delayed )
{
    if ( delayed == this )
    {
        return 0;
    }

    if ( delayed instanceof QueuedAudit )
    {
        long diff = delay - ((QueuedAudit) delayed).delay;
        return ((diff == 0) ? 0 : ((diff < 0) ? -1 : 1));
    }

    long d = (getDelay( TimeUnit.MILLISECONDS ) - delayed.getDelay( TimeUnit.MILLISECONDS ));

    return ((d == 0) ? 0 : ((d < 0) ? -1 : 1));
}
 
@Override
public int compareTo(@Nonnull Delayed o) {
	if (o == this) {
		return 0;
	}

	long diff = getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS);
	return (diff < 0L) ? -1 : (diff > 0L) ? 1 : 0;
}
 
源代码11 项目: litchi   文件: DelayedSession.java
@Override
public int compareTo(Delayed o) {
    if (o.getDelay(TimeUnit.MILLISECONDS) < this.getDelay(TimeUnit.MILLISECONDS)) {
        return 1;
    } else if (o.getDelay(TimeUnit.MILLISECONDS) > this.getDelay(TimeUnit.MILLISECONDS)) {
        return -1;
    }
    return 0;
}
 
源代码12 项目: lams   文件: ReschedulingRunnable.java
@Override
public int compareTo(Delayed other) {
	if (this == other) {
		return 0;
	}
	long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
	return (diff == 0 ? 0 : ((diff < 0)? -1 : 1));
}
 
源代码13 项目: MaxKey   文件: InMemoryTokenStore.java
public int compareTo(Delayed other) {
	if (this == other) {
		return 0;
	}
	long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
	return (diff == 0 ? 0 : ((diff < 0) ? -1 : 1));
}
 
@Override
public int compareTo(Delayed other) {
	if (this == other) {
		return 0;
	}
	long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
	return (diff == 0 ? 0 : ((diff < 0)? -1 : 1));
}
 
源代码15 项目: hbase   文件: LeaseManager.java
@Override
public int compareTo(Delayed o) {
  long delta = this.getDelay(TimeUnit.MILLISECONDS) -
    o.getDelay(TimeUnit.MILLISECONDS);

  return this.equals(o) ? 0 : (delta > 0 ? 1 : -1);
}
 
源代码16 项目: netbeans   文件: RequestProcessor.java
@Override
public int compareTo(Delayed o) {
    long other = o.getDelay(TimeUnit.MILLISECONDS);
    long ours = getDelay(TimeUnit.MILLISECONDS);
    //Might overflow on, say, ms compared to Long.MAX_VALUE, TimeUnit.DAYS
    return (int) (ours - other);
}
 
@Override
public int compareTo(Delayed other) {
	if (this == other) {
		return 0;
	}
	long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
	return (diff == 0 ? 0 : ((diff < 0)? -1 : 1));
}
 
源代码18 项目: exhibitor   文件: RefCountedClient.java
@Override
public int compareTo(Delayed o)
{
    long            diff = getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS);
    return (diff < 0) ? -1 : ((diff > 0) ? 1 : 0);
}
 
源代码19 项目: hbase   文件: ConstantDelayQueue.java
@Override
public int compareTo(Delayed o) {
  long cmp = getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS);
  return cmp == 0 ? 0 : ( cmp < 0 ? -1 : 1);
}
 
源代码20 项目: sissi   文件: PingKeepalive.java
public int compareTo(Delayed o) {
	return o.getDelay(TimeUnit.MILLISECONDS) >= this.getDelay(TimeUnit.MILLISECONDS) ? 1 : -1;
}
 
 方法所在类
 同类方法