|
|||||||||
| Home >> All >> EDU >> oswego >> cs >> dl >> util >> [ concurrent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
EDU.oswego.cs.dl.util.concurrent
Class BoundedBuffer

java.lang.ObjectEDU.oswego.cs.dl.util.concurrent.BoundedBuffer
- All Implemented Interfaces:
- BoundedChannel, Channel, Puttable, Takable
- public class BoundedBuffer
- extends java.lang.Object
- implements BoundedChannel
- extends java.lang.Object
Efficient array-based bounded buffer class. Adapted from CPJ, chapter 8, which describes design.
[ Introduction to this package. ]
| Field Summary | |
protected java.lang.Object[] |
array_
|
protected int |
emptySlots_
|
protected java.lang.Object |
putMonitor_
Helper monitor to handle puts. |
protected int |
putPtr_
|
protected int |
takePtr_
|
protected int |
usedSlots_
|
| Constructor Summary | |
BoundedBuffer()
Create a buffer with the current default capacity |
|
BoundedBuffer(int capacity)
Create a BoundedBuffer with the given capacity. |
|
| Method Summary | |
int |
capacity()
Return the maximum number of elements that can be held. |
protected java.lang.Object |
extract()
|
protected void |
incEmptySlots()
|
protected void |
incUsedSlots()
|
protected void |
insert(java.lang.Object x)
|
boolean |
offer(java.lang.Object x,
long msecs)
Place item in channel only if it can be accepted within msecs milliseconds. |
java.lang.Object |
peek()
Return, but do not remove object at head of Channel, or null if it is empty. |
java.lang.Object |
poll(long msecs)
Return and remove an item from channel only if one is available within msecs milliseconds. |
void |
put(java.lang.Object x)
Place item in the channel, possibly waiting indefinitely until it can be accepted. |
int |
size()
Return the number of elements in the buffer. |
java.lang.Object |
take()
Return and remove an item from channel, possibly waiting indefinitely until such an item exists. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
array_
protected final java.lang.Object[] array_
takePtr_
protected int takePtr_
putPtr_
protected int putPtr_
usedSlots_
protected int usedSlots_
emptySlots_
protected int emptySlots_
putMonitor_
protected final java.lang.Object putMonitor_
- Helper monitor to handle puts.
| Constructor Detail |
BoundedBuffer
public BoundedBuffer(int capacity)
throws java.lang.IllegalArgumentException
- Create a BoundedBuffer with the given capacity.
BoundedBuffer
public BoundedBuffer()
- Create a buffer with the current default capacity
| Method Detail |
size
public int size()
- Return the number of elements in the buffer.
This is only a snapshot value, that may change
immediately after returning.
capacity
public int capacity()
- Description copied from interface:
BoundedChannel - Return the maximum number of elements that can be held.
- Specified by:
capacityin interfaceBoundedChannel
incEmptySlots
protected void incEmptySlots()
incUsedSlots
protected void incUsedSlots()
insert
protected final void insert(java.lang.Object x)
extract
protected final java.lang.Object extract()
peek
public java.lang.Object peek()
- Description copied from interface:
Channel - Return, but do not remove object at head of Channel,
or null if it is empty.
put
public void put(java.lang.Object x) throws java.lang.InterruptedException
- Description copied from interface:
Channel - Place item in the channel, possibly waiting indefinitely until
it can be accepted. Channels implementing the BoundedChannel
subinterface are generally guaranteed to block on puts upon
reaching capacity, but other implementations may or may not block.
offer
public boolean offer(java.lang.Object x, long msecs) throws java.lang.InterruptedException
- Description copied from interface:
Channel - Place item in channel only if it can be accepted within
msecs milliseconds. The time bound is interpreted in
a coarse-grained, best-effort fashion.
take
public java.lang.Object take() throws java.lang.InterruptedException
- Description copied from interface:
Channel - Return and remove an item from channel,
possibly waiting indefinitely until
such an item exists.
poll
public java.lang.Object poll(long msecs) throws java.lang.InterruptedException
- Description copied from interface:
Channel - Return and remove an item from channel only if one is available within
msecs milliseconds. The time bound is interpreted in a coarse
grained, best-effort fashion.
|
|||||||||
| Home >> All >> EDU >> oswego >> cs >> dl >> util >> [ concurrent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
EDU.oswego.cs.dl.util.concurrent.BoundedBuffer