|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--se.lth.cs.realtime.RTThread | +--se.lth.cs.realtime.CyclicThread | +--se.lth.cs.realtime.SporadicThread
This class models a real-time thread that executes the same function every time it is triggered.
The execution frequency must be upper-bound specifying a shortest period
for this thread(if FixedPeriod
is implemented, the shortest
period can be modified only before this thread is started).
Being a CyclicThread
,
a SporadicThread
may be suspended and resumed
by other threads. By default, the "triggering events"
that occurre during the suspension time are served after the
resumption.
Field Summary | |
protected int |
pendingTriggers
Checked in waitToPerform to let this thread stop waiting. |
Fields inherited from class se.lth.cs.realtime.RTThread |
defaultEventBufferSize, listenerList, mailbox, MAX_PRIORITY, MIN_PRIORITY |
Constructor Summary | |
SporadicThread(long shortestPeriod)
Allocates a new SporadicThread object. |
|
SporadicThread(RTThreadGroup group,
long shortestPeriod)
Allocates a new SporadicThread object. |
|
SporadicThread(RTThreadGroup group,
java.lang.String name,
boolean privateQueue,
long shortestPeriod)
Allocates a new SporadicThread object. |
|
SporadicThread(RTThreadGroup group,
java.lang.String name,
long shortestPeriod)
Allocates a new SporadicThread object. |
|
SporadicThread(java.lang.String name,
long shortestPeriod)
Allocates a new SporadicThread object. |
Method Summary | |
long |
getShortestPeriod()
Returns the shortest period of this thread, in milliseconds. |
protected void |
perform()
Does nothing. |
void |
setShortestPeriod(long shortestPeriod)
Sets the shortest period of this thread, in milliseconds. |
java.lang.String |
toString()
Returns a string representation of this thread, including the thread's name, priority and shortest period in milliseconds. |
void |
trigger()
Causes the execution of the perform method. |
protected void |
waitToPerform()
Lets this thread wait for a call to the function trigger . |
Methods inherited from class se.lth.cs.realtime.CyclicThread |
isSuspended, onResuming, resume, run, stop, suspend |
Methods inherited from class se.lth.cs.realtime.RTThread |
currentRTThread, dumpStack, getName, getPriority, getRTThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, putEvent, setDaemon, setName, setPriority, sleep, sleep, sleepUntil, start, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected volatile int pendingTriggers
waitToPerform
to let this thread stop waiting.
Note that its value is decremented when returning from waitToPerform
.Constructor Detail |
public SporadicThread(long shortestPeriod)
SporadicThread
object.
Equivalent to SporadicThread(null, null, true, shortestPeriod)
.
shortestPeriod
- the shortest period of the new thread, in milliseconds.java.lang.IllegalArgumentException
- if the shortest period is not positive.SporadicThread(RTThreadGroup, java.lang.String, boolean, long)
public SporadicThread(java.lang.String name, long shortestPeriod)
SporadicThread
object.
Equivalent to SporadicThread(null, name, true, shortestPeriod)
.
name
- the name of the new thread.shortestPeriod
- the shortest period of the new thread, in milliseconds.java.lang.IllegalArgumentException
- if the shortest period is not positive.SporadicThread(RTThreadGroup, java.lang.String, boolean, long)
public SporadicThread(RTThreadGroup group, long shortestPeriod)
SporadicThread
object.
Equivalent to SporadicThread(group, null, true, shortestPeriod)
.
group
- this thread's RTThreadGroup
..shortestPeriod
- the shortest period of the new thread, in milliseconds.java.lang.IllegalArgumentException
- if the shortest period is not positive.SporadicThread(RTThreadGroup, java.lang.String, boolean, long)
public SporadicThread(RTThreadGroup group, java.lang.String name, long shortestPeriod)
SporadicThread
object.
Equivalent to SporadicThread(group, name, true, shortestPeriod)
.
name
- the name of the new thread.group
- this thread's RTThreadGroup
..shortestPeriod
- the shortest period of the new thread, in milliseconds.java.lang.IllegalArgumentException
- if the shortest period is not positive.SporadicThread(RTThreadGroup, java.lang.String, boolean, long)
public SporadicThread(RTThreadGroup group, java.lang.String name, boolean privateQueue, long shortestPeriod)
SporadicThread
object.
It is possible to specify whether this thread should use a private object to wait on, when suspended or waiting to be triggered.
name
- the name of the new thread.group
- this thread's RTThreadGroup
..privateQueue
- whether this thread should use a private queue.shortestPeriod
- the shortest period of the new thread, in milliseconds.java.lang.IllegalArgumentException
- if the shortest period is not positive.CyclicThread.CyclicThread(RTThreadGroup, java.lang.String, boolean)
Method Detail |
public void trigger() throws FrequencyExcessException
perform
method.
If called before shortestPeriod
milliseconds
since the last call, an exception is thrown.FrequencyExcessException
- if called too often.IllegalThreadStateException
- if the thread has not
been started.protected void perform()
TriggeredEvent
generator only.perform
in class CyclicThread
event.TriggeredEvent
protected void waitToPerform() throws java.lang.InterruptedException
trigger
.waitToPerform
in class CyclicThread
java.lang.InterruptedException
- if another thread has interrupted this one.public long getShortestPeriod()
public void setShortestPeriod(long shortestPeriod) throws FixedPeriodException
FixedPeriod
and is
alive , an exception is thrown.shortestPeriod
- the new shortest period of this thread.java.lang.IllegalArgumentException
- if the argument is not positive.FixedPeriodException
- if the thread is alive and implements
FixedPeriod
.public java.lang.String toString()
toString
in class CyclicThread
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |