CSTimer.java 2.05 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov Date: 26/10/2010 14:06:00
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)

package jcircus.classesdescompiladas;


// Referenced classes of package org.jcsp.lang:
// Guard, ProcessInterruptedException, Spurious, Alternative

public class CSTimer extends Guard
{

public CSTimer()
{
msecs = 0L;
}

public void setAlarm(long l)
{
msecs = l;
}

public long getAlarm()
{
return msecs;
}

/**
* @deprecated Method set is deprecated
*/

public void set(long l)
{
msecs = l;
}

public long read()
{
return System.currentTimeMillis();
}

public void after(long l)
{
long l1 = l - System.currentTimeMillis();
if(l1 > 0L)
try
{
Thread.sleep(l1);
}
catch(InterruptedException interruptedexception)
{
throw new ProcessInterruptedException("*** Thrown from CSTimer.after (long)\n" + interruptedexception.toString());
}
}

public void sleep(long l)
{
if(l > 0L)
try
{
Thread.sleep(l);
}
catch(InterruptedException interruptedexception)
{
throw new ProcessInterruptedException("*** Thrown from CSTimer.sleep (long)\n" + interruptedexception.toString());
}
}

boolean enable(Alternative alternative)
{
if(msecs - System.currentTimeMillis() <= Spurious.earlyTimeout)
{
return true;
} else
{
alternative.setTimeout(msecs);
return false;
}
}

boolean disable()
{
return msecs - System.currentTimeMillis() <= Spurious.earlyTimeout;
}

private long msecs;
}