mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
30 lines
506 B
Java
30 lines
506 B
Java
package com.volmit.iris.util;
|
|
|
|
public class ChronoLatch
|
|
{
|
|
private long interval;
|
|
private long since;
|
|
|
|
public ChronoLatch(long interval, boolean openedAtStart)
|
|
{
|
|
this.interval = interval;
|
|
since = System.currentTimeMillis() - (openedAtStart ? interval * 2 : 0);
|
|
}
|
|
|
|
public ChronoLatch(long interval)
|
|
{
|
|
this(interval, true);
|
|
}
|
|
|
|
public boolean flip()
|
|
{
|
|
if(System.currentTimeMillis() - since > interval)
|
|
{
|
|
since = System.currentTimeMillis();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|