Methods Summary |
---|
public synchronized boolean | canRead()returns true if read() would succeed
return (availableFramesForReading > 0);
|
public synchronized boolean | canWrite()returns true if getEmptyObject() would succeed
return (availableFramesForWriting>0);
|
public void | error()error dump
throw new RuntimeException ("CircularQueue failure:\n head="+head+"\n tail="+tail+
"\n canRead="+availableFramesForReading+"\n canWrite="+availableFramesForWriting+
"\n lockedRead="+lockedFramesForReading+"\n lockedWrite="+lockedFramesForWriting);
|
public synchronized javax.media.Buffer | getEmptyBuffer()returns empty buffer object to put data in
if (availableFramesForWriting == 0)
error();
lockedFramesForWriting++;
Buffer buffer = buf[tail];
availableFramesForWriting--;
tail++;
if (tail >= size)
tail -= size;
return buffer;
|
public synchronized boolean | lockedRead()
return (lockedFramesForReading > 0);
|
public synchronized boolean | lockedWrite()
return (lockedFramesForWriting > 0);
|
public synchronized javax.media.Buffer | peek()Gets frame with valid buffer from the queue
if (availableFramesForReading == 0)
error();
return buf[head];
|
public void | print()
System.err.println("CircularQueue : head="+head+" tail="+tail+
" canRead="+availableFramesForReading+" canWrite="+availableFramesForWriting+
" lockedRead="+lockedFramesForReading+" lockedWrite="+lockedFramesForWriting);
|
public synchronized javax.media.Buffer | read()Gets frame with valid buffer from the queue
if (availableFramesForReading == 0)
error();
Buffer buffer = buf[head];
lockedFramesForReading++;
availableFramesForReading--;
head++;
if (head >= size)
head -= size;
return buffer;
|
public synchronized void | readReport()indicates that the latest read frame is no longer in use
if (lockedFramesForReading == 0)
error();
lockedFramesForReading--;
availableFramesForWriting++;
|
public synchronized void | reset()reset the queue
availableFramesForReading = 0;
availableFramesForWriting = size;
lockedFramesForReading = 0;
lockedFramesForWriting = 0;
head = 0;
tail = 0;
|
public synchronized void | writeReport()indicates that latest Object returns to the queue
we removed writeReport(false), since we have the mechanism in javax.media.Buffer (discard).
if (lockedFramesForWriting == 0)
error();
lockedFramesForWriting--;
availableFramesForReading++; // wrote data OK
/*
@@@ buffer invalid: removed since we have the mechanism in javax.media.Buffer
{
availableFramesForWriting++; // buffer not written
tail--;
if (tail<0)
tail += size;
}
*/
|