|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.java2C.test.TestWaitNotify.TestThreadLocalData
private static final class TestWaitNotify.TestThreadLocalData
This class is defined only to use in the threads context. No other thread should have access to it.
Therefore the instance can be defined in a thread-local data range. For Java2C it is possible
to create a stack-instance.
| Field Summary | |
|---|---|
(package private) int |
seqCt
A sequence counter which holds the last value of TestWaitNotify.WaitNotifyData.ctNewData to check
whether all data are got. |
(package private) int |
seqCtLast
A sequence counter which holds the last value of TestWaitNotify.WaitNotifyData.ctNewData to check
whether all data are got. |
(package private) int |
testCtInterrupted
This counter is used to test whether the interrupting of the thread works. |
(package private) int |
testCtMissNotify
|
(package private) int |
testCtNothingReceived
|
(package private) int |
testCtSuccessNotify
|
private TestWaitNotify.WaitNotifyData |
theAwaitingData
Association to the data which are notifying from outside. |
(package private) int |
x
|
(package private) int |
y
|
| Constructor Summary | |
|---|---|
TestWaitNotify.TestThreadLocalData(TestWaitNotify.WaitNotifyData theAwaitingDataP)
|
|
| Method Summary | |
|---|---|
private void |
awaitData()
In this routine the thread is waiting for data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
int x
int y
int seqCtLast
TestWaitNotify.WaitNotifyData.ctNewData to check
whether all data are got.
int seqCt
TestWaitNotify.WaitNotifyData.ctNewData to check
whether all data are got.
int testCtInterrupted
int testCtNothingReceived
int testCtSuccessNotify
int testCtMissNotify
private final TestWaitNotify.WaitNotifyData theAwaitingData
| Constructor Detail |
|---|
TestWaitNotify.TestThreadLocalData(TestWaitNotify.WaitNotifyData theAwaitingDataP)
| Method Detail |
|---|
private void awaitData()
synchronized(theAwaitingData){
if(seqCtLast == -1){
seqCt = seqCtLast = theAwaitingData.ctNewData;
}
theAwaitingData.wait(1000);
seqCt = theAwaitingData.ctNewData; //same as seqCtLast if no notify is called.
valueFromAwaitingData = theAwaitingData.x;
}
This is translated to C in form:
synchronized_ObjectJc(& ((* (REFJc(ythis->theAwaitingData))).base.object)); {
if(ythis->seqCtLast == -1)
{
ythis->seqCt = ythis->seqCtLast = REFJc(ythis->theAwaitingData)->ctNewData;
}
wait_ObjectJc(& ((*(REFJc(ythis->theAwaitingData))).base.object), 1000, _thCxt);
ythis->seqCt = REFJc(ythis->theAwaitingData)->ctNewData;
valueFromAwaitingData = REFJc(ythis->theAwaitingData)->x;
} endSynchronized_ObjectJc(& ((* (REFJc(ythis->theAwaitingData))).base.object));
The rest of code tests the seqCt. If new data are available, the seqCt is incremented for 1.
If a notify is missed, the counter is incremented for greater 1. If no notify is occured,
but the wait time is out, the seqCt isn't incremented. This three conditions are tested,
and the appropriate counters are counted. The counters give an overview of occurrence
while running the process. Last not least the value given by notify is processed. But it is
only an example.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||