Producer Consumer
 All Classes Namespaces Files Functions Variables Properties
Public Member Functions | Properties | List of all members
producerConsumer.BoundedBuffer Class Reference

BoundedBuffer has a limited capacity.
Trying to Add an element to a full buffer will make the calling thread wait. This class is thread safe. More...

Inherits producerConsumer.AbstractBuffer.

Public Member Functions

 BoundedBuffer (int capacity)
 Constructs a new BoundedBuffer object More...
 
Boolean IsFull ()
 Returns true if the buffer is full, false otherwise More...
 
override void Add (int element)
 Adds an element into the end of this buffer.
If the buffer is full, the calling thread will wait until another thread has taken an element from the buffer More...
 
override int Take ()
 Removes and returns the first element from this buffer.
If the buffer is empty, the thread calling Tak() must wait until another thread Puts an element. More...
 
- Public Member Functions inherited from producerConsumer.AbstractBuffer
Boolean IsEmpty ()
 Returns true if the buffer is empty, false otherwise More...
 

Properties

int Capacity [get]
 
- Properties inherited from producerConsumer.AbstractBuffer
int Count [get]
 
- Properties inherited from producerConsumer.IBuffer
int Count [get]
 The number of elements currently in the buffer More...
 

Additional Inherited Members

- Protected Attributes inherited from producerConsumer.AbstractBuffer
readonly Queue< int > Queue = new Queue<int>()
 

Detailed Description

BoundedBuffer has a limited capacity.
Trying to Add an element to a full buffer will make the calling thread wait. This class is thread safe.

Constructor & Destructor Documentation

producerConsumer.BoundedBuffer.BoundedBuffer ( int  capacity)

Constructs a new BoundedBuffer object

Parameters
capacityThe capacity of the BoundedBuffer object
Exceptions
ArgumentOutOfRangeExceptionIf the capacity is less than or equal to zero

Member Function Documentation

override void producerConsumer.BoundedBuffer.Add ( int  element)
virtual

Adds an element into the end of this buffer.
If the buffer is full, the calling thread will wait until another thread has taken an element from the buffer

Parameters
elementnew element to be added into this buffer

Implements producerConsumer.AbstractBuffer.

Boolean producerConsumer.BoundedBuffer.IsFull ( )

Returns true if the buffer is full, false otherwise

Returns
true if the buffer is full, false otherwise
override int producerConsumer.BoundedBuffer.Take ( )
virtual

Removes and returns the first element from this buffer.
If the buffer is empty, the thread calling Tak() must wait until another thread Puts an element.

Returns
The first element from this buffer

Implements producerConsumer.AbstractBuffer.

Property Documentation

int producerConsumer.BoundedBuffer.Capacity
get

The documentation for this class was generated from the following file: