|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectse.lth.cs.realtime.RTSystem
se.lth.cs.realtime.Condition
Providing enhanced {wait() | wait(timeout) | notify() | notifyAll()}
methods, acting on the already locked object provided as the first argument for
all methods. That is, the calling thread must first own the monitor lock via the
use of synchronized. The enhancements are:
wait
refers to the time
maintained by the RTSystem
baseclass.
If RTSystem.REAL_TIME
is true, that time is the real time of
the system, and Condition.wait(timeout)
is equivalent to
Object.wait(timeout)
.
If RTSystem.REAL_TIME
is false, which should be the case when
the application is run within a debugger, time stops when for instance the
application/JVM is stopped at a breakpoint. Thus, timeouts due to debugging
are avoided.
wait
methods do no longer throw InterruptedException
.
Instead, the error RTInterrupted
is thrown, which optionally
can be cought but that is not required. Thereby, the risky leftovers of lazy
programming, such as try {wait();} catch (Exception exc){};
, should
be avoided since it is even simpler to call Condition.wait(this);
wait
and notify
should support
condition objects. However, this remains to be implemented.
notify()
and notifyAll()
are not changed; they are
included here for completeness and simply calls the corresponding method in
Object
.
Remark: The inheritance from RTSystem is purely for the implementation of wait with timeout, optionally based on virtual time suitable for debugging.
Field Summary |
Fields inherited from class se.lth.cs.realtime.RTSystem |
lag, PRIORITY_BASED, PRIORITY_STRICT, REAL_TIME, seq, TICK_BASED, TIMEOUT_MS, TIMEOUT_NS, tol |
Constructor Summary | |
Condition()
|
Method Summary | |
static void |
notify(java.lang.Object monitor)
Replacement for java.lang.Object.notify() . |
static void |
notifyAll(java.lang.Object monitor)
Replacement for java.lang.Object.wait() . |
static void |
wait(java.lang.Object monitor)
Replacement for java.lang.Object.wait() . |
static void |
wait(java.lang.Object monitor,
long timeout)
Call wait(timeout) in monitor , but
considering application time before return. |
Methods inherited from class se.lth.cs.realtime.RTSystem |
currentTimeMillis, getDefaultEventBufferSize, getMaxEventBufferSize, getTickMillis, getTickNanos, sleep, sleep, sleepUntil |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Condition()
Method Detail |
public static void notify(java.lang.Object monitor)
java.lang.Object.notify()
.
monitor
- the monitor that the caller has locked via synchronized.
java.lang.IllegalMonitorStateException
- when the monitor is not held by
the calling thread.public static void notifyAll(java.lang.Object monitor)
java.lang.Object.wait()
.
monitor
- the monitor that the caller has synchronized upon.
RTInterrupted
- when the calling thread has been interrupted.
java.lang.IllegalMonitorStateException
- when the monitor is not held by
the calling thread.public static void wait(java.lang.Object monitor)
java.lang.Object.wait()
.
monitor
- the monitor that the caller have synchronized upon.
RTInterrupted
- when the calling thread has been interrupted.
java.lang.IllegalMonitorStateException
- when the monitor is not held by
the calling thread.public static void wait(java.lang.Object monitor, long timeout)
wait(timeout)
in monitor
, but
considering application time before return.
monitor
- The object in which notify is waited for.timeout
- The waiting time after which we want to give up.
java.lang.IllegalMonitorStateException
- when the monitor is not held by
the calling thread.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |