All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Foundation |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.services.util
Class Waiter

    com.sas.services.util.Waiter

    public class Waiter

Waiter class. This is used in conjunction with `WaitPolicy`.

Typical use is for the application which needs to follow a WaitPolicy to construct a Waiter and if the resource in question is not available call `sleep()` until it is or sleep() returns false.

Constructor Summary
`Waiter(WaitPolicy waitPolicy)` Constructs a Waiter from a `WaitPolicy`.

Method Summary
`long` | `getTotalTimeWaited()` Returns the total time spent waiting at the time of this method call.
`boolean` | `sleep()` Sleep as dictated by the policy.

Constructor Detail

### Waiter

    public Waiter(WaitPolicy waitPolicy)

  Constructs a Waiter from a `WaitPolicy`. After the constructor returns the WaitPolicy object is no longer needed.

  Parameters:
    `waitPolicy` -

Method Detail

### sleep

    public boolean sleep()
                  throws java.lang.InterruptedException

  Sleep as dictated by the policy.

  In the discussion that follows the variables referred to use the names of the parameters of `WaitPolicy.WaitPolicy(TYPE, int, int, int, int, long)`. initialWait sets the time for the first sleep. waitIncrement can be either positive or negative and subsequent sleep periods are adjusted by waitIncrement, subject to the bounds imposed by minimumWait and maximumWait. If the WaitPolicy is of type `WaitPolicy.TYPE.FINITE` then the final sleep period is adjusted so that totalWait is not exceeded.

  Do note the various times determine how long the method sleeps and no attempt is made to adjust for time spent performing other operations.

  Returns:
    true: sleep was invoked; false: sleep was not invoked because total wait time was exceeded or policy type was `WaitPolicy.TYPE.NONE`
  Throws:
    `java.lang.InterruptedException` - if the call to Thread.sleep() which is used to implement "sleep" throws an InterruptedException.

### getTotalTimeWaited

    public long getTotalTimeWaited()

  Returns the total time spent waiting at the time of this method call.

  Returns:

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Foundation |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.