|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.runtime.Interlock org.eigenbase.runtime.ExclusivePipe
public class ExclusivePipe
A synchronization primitive which allows producer and a consumer to use the
same Buffer
without treading on each other's feet.
This class is synchronous: only one of the producer and consumer has access at a time. There is only one buffer, and data is not copied.
The byte buffer is fixed in size. The producer writes up to the maximum number of bytes into the buffer, then yields. The consumer must read all of the data in the buffer before yielding back to the producer.
Field Summary | |
---|---|
private ByteBuffer |
buf
|
Constructor Summary | |
---|---|
ExclusivePipe(ByteBuffer buf)
|
Method Summary | |
---|---|
void |
beginReading()
Acquires the buffer, in preparation for reading. |
void |
beginWriting()
Acquires the buffer, in preparation for writing. |
ByteBuffer |
getBuffer()
Returns the buffer. |
Methods inherited from class org.eigenbase.runtime.Interlock |
---|
endReading, endWriting |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final ByteBuffer buf
Constructor Detail |
---|
public ExclusivePipe(ByteBuffer buf)
Method Detail |
---|
public ByteBuffer getBuffer()
public void beginWriting()
Interlock
The producer should call this method. After this call completes, the
consumer's call to Interlock.beginReading()
will block until the producer
has called Interlock.endWriting()
.
beginWriting
in class Interlock
public void beginReading()
Interlock
After this call completes, the producer's call to Interlock.beginWriting()
will block until the consumer has called Interlock.endReading()
.
beginReading
in class Interlock
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |