com.kuka.roboticsAPI.concurrencyModel
Class CriticalArea

java.lang.Object
  extended by com.kuka.roboticsAPI.concurrencyModel.CriticalArea

public final class CriticalArea
extends Object

Care class. Each area is identified through a name. If any other thread tries to access the same area, it has to wait until no other thread is in this area.

This element is not in its final state and might change in future versions.

Constructor Summary
CriticalArea(String name)
          Creates an instance of the CriticalArea class.
 
Method Summary
 boolean enter()
          Enters the critical area.
 void exit()
          Leaves the critical area.
 String getName()
          Gets a name of the critical area.
 boolean tryEnter(long time, TimeUnit unit)
          Enters the critical area if it is free within the given waiting time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CriticalArea

public CriticalArea(String name)
Creates an instance of the CriticalArea class.

Parameters:
name - name for the critical area.
This element is not in its final state and might change in future versions.
Method Detail

getName

public String getName()
Gets a name of the critical area.

Returns:
a name of the critical area.
This element is not in its final state and might change in future versions.

enter

public boolean enter()
Enters the critical area. Until "leave" is called, no thread can enter this area unless the calling thread.

Returns:
true if the lock was acquired and false if the thread was interrupted while waiting.
This element is not in its final state and might change in future versions.

tryEnter

public boolean tryEnter(long time,
                        TimeUnit unit)
Enters the critical area if it is free within the given waiting time.

Parameters:
time - the maximum time to wait
unit - the time unit of the time argument
Returns:
true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.
This element is not in its final state and might change in future versions.

exit

public void exit()
Leaves the critical area.

This element is not in its final state and might change in future versions.


Copyright © 2019. All rights reserved.