|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectse.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 occur during the suspension time are served after the
resumption.
License
Field Summary | |
protected int |
failedTriggerCount
|
Fields inherited from class se.lth.cs.realtime.CyclicThread |
suspendLock |
Fields inherited from class se.lth.cs.realtime.RTThread |
defaultBufferSize, dispatcher, mailbox, MAX_PRIORITY, MIN_PRIORITY, NORM_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,
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. |
int |
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 |
addListener, currentRTThread, currentThread, dumpStack, getDispatcher, getEnv, getMaxTimeLag, getName, getPriority, getRTThreadId, getThreadGroup, getTimebase, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, putEvent, setDaemon, setMaxTimeLag, setName, setPriority, sleep, sleep, sleepUntil, start, terminate, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected volatile int failedTriggerCount
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,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, 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, 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,long)
Method Detail |
public long getShortestPeriod()
protected void perform()
TriggerEvent
generator only.
perform
in class CyclicThread
TriggerEvent
public void setShortestPeriod(long shortestPeriod) throws FixedPeriodError
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.
FixedPeriodError
- if the thread is alive and implements
FixedPeriod
.public java.lang.String toString()
toString
in class CyclicThread
public int trigger()
perform
method.
Each SporadicThread can have at most one triggering thread.
The first RTThread which tries to trigger this thread will
be the triggering thread.
protected void waitToPerform() throws java.lang.InterruptedException
trigger
.
waitToPerform
in class CyclicThread
java.lang.InterruptedException
- if another thread has interrupted this one.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |