本文整理汇总了Java中java.util.concurrent.Delayed.getDelay方法的典型用法代码示例。如果您正苦于以下问题:Java Delayed.getDelay方法的具体用法?Java Delayed.getDelay怎么用?Java Delayed.getDelay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.Delayed
的用法示例。
在下文中一共展示了Delayed.getDelay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed o) {
if (o == null)
return 1;
if (o == this)
return 0;
if (o instanceof DelayedItem) {
DelayedItem<T> tmpDelayedItem = (DelayedItem<T>) o;
if (liveTime > tmpDelayedItem.liveTime) {
return 1;
} else if (liveTime == tmpDelayedItem.liveTime) {
return 0;
} else {
return -1;
}
}
long diff = getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS);
return diff > 0 ? 1 : diff == 0 ? 0 : -1;
}
示例2: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed other) {
if (this == other) {
return 0;
}
long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
if (diff == 0) {
return 0;
}
if (diff < 0) {
return -1;
}
return 1;
}
示例3: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
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);
}
示例4: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@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);
}
示例5: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
public int compareTo(Delayed other) {
if (other == this) {
return 0;
}
if (other instanceof DelayedTimer) {
DelayedTimer x = (DelayedTimer) 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);
}
示例6: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@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;
}
}
示例7: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed delayed) {
long me = getDelay(TimeUnit.MILLISECONDS);
long other = delayed.getDelay(TimeUnit.MILLISECONDS);
if (me < other) {
return -1;
} if (me > other) {
return 1;
} else {
return 0;
}
}
示例8: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@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);
}
示例9: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@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));
}
示例10: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
public int compareTo(Delayed other) {
if (other == this) { // compare zero ONLY if same object
return 0;
} else if (other instanceof DeadNodeDelayed) {
DeadNodeDelayed x = (DeadNodeDelayed) other;
long diff = now + timeout - (x.now + x.timeout);
return (diff == 0) ? 0 : ((diff < 0) ? 1 : -1); // 时间越小的,越应该排在前面
} else {
long d = (getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS));
return (d == 0) ? 0 : ((d < 0) ? 1 : -1);
}
}
示例11: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
public int compareTo(Delayed other) {
if (other == this) { // compare zero ONLY if same object
return 0;
} else if (other instanceof AlarmRecoveryDelayed) {
AlarmRecoveryDelayed x = (AlarmRecoveryDelayed) other;
long diff = now + timeout - (x.now + x.timeout);
return (diff == 0) ? 0 : ((diff < 0) ? 1 : -1); // 时间越小的,越应该排在前面
} else {
long d = (getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS));
return (d == 0) ? 0 : ((d < 0) ? 1 : -1);
}
}
示例12: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
/**
* Method to compare two events
*/
@Override
public int compareTo(Delayed o) {
long result = this.getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS);
if (result < 0) {
return -1;
} else if (result > 0) {
return 1;
}
return 0;
}
示例13: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed o) {
if (o instanceof Event) {
Event other = (Event) o;
if (this == other) {
return 0;
}
return Long.valueOf(this.time).compareTo(other.time);
}
long d = (getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS));
return (d == 0) ? 0 : ((d < 0) ? -1 : 1);
}
示例14: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed o) {
if (o instanceof SessionHolder) {
SessionHolder other = (SessionHolder) o;
if (this == other) {
return 0;
}
return Long.valueOf(this.crawlerSession.getLastActiveTimeStamp())
.compareTo(other.crawlerSession.getLastActiveTimeStamp());
}
long d = (getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS));
return (d == 0) ? 0 : ((d < 0) ? -1 : 1);
}
示例15: compareTo
import java.util.concurrent.Delayed; //导入方法依赖的package包/类
@Override
public int compareTo(Delayed o) {
long result = this.getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS);
if (result > 0) {
return 1;
} else if (result < 0) {
return -1;
} else {
return 0;
}
}