se.lth.cs.realtime
Class Condition.Factory

java.lang.Object
  extended byse.lth.cs.realtime.Condition.Factory
Enclosing class:
Condition

public static final class Condition.Factory
extends java.lang.Object

A factory which creates condition variables.


Constructor Summary
Condition.Factory()
          This constructor should be used when condition variables will be used within synchronized block and the object, which is used for synchronization, only will be used in the calling object.
Condition.Factory(Monitor monitor)
          This constructor should be used when condition variables will be used within a Monitor.
Condition.Factory(MutexSem mutex)
          This constructor should be used when condition variables are used in combination with a mutual exclusion semaphore.
Condition.Factory(Synchronized.Lock syncObj)
          This constructor should be used when condition variables will be used within synchronized blocks and the object, which is used for synchronization, need to be used elsewhere.
 
Method Summary
 int getCondCount()
          Returns the number of condition variables created by this factory.
 Condition newCondition()
          Creates a new condition variable.
 Synchronized.Lock obtainLock()
          This method returns the lock object of this factory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition.Factory

public Condition.Factory(MutexSem mutex)
This constructor should be used when condition variables are used in combination with a mutual exclusion semaphore.

Parameters:
mutex - The mutual exclusion semaphore.
See Also:
MutexSem

Condition.Factory

public Condition.Factory(Monitor monitor)
This constructor should be used when condition variables will be used within a Monitor.

Parameters:
monitor - The monitor object.
See Also:
Monitor

Condition.Factory

public Condition.Factory(Synchronized.Lock syncObj)
This constructor should be used when condition variables will be used within synchronized blocks and the object, which is used for synchronization, need to be used elsewhere.

Parameters:
syncObj - The synchronization object.
See Also:
Synchronized

Condition.Factory

public Condition.Factory()
This constructor should be used when condition variables will be used within synchronized block and the object, which is used for synchronization, only will be used in the calling object. A new lock object will be constructed which can be obtained by calling obtainLock().

Method Detail

obtainLock

public final Synchronized.Lock obtainLock()
This method returns the lock object of this factory. Calls to this method will only be successful if the factory was created with the purpose of creating condition variables to be used within synchronized blocks.

Returns:
The lock object of this factory.
Throws:
java.lang.UnsupportedOperationException - When a call is made to a factory constructed to support mutex or monitor synchronization.

getCondCount

public final int getCondCount()
Returns the number of condition variables created by this factory.

Returns:
The number of condition variables.

newCondition

public final Condition newCondition()
Creates a new condition variable.

Returns:
A new condition variable object.