com.atlassian.util.concurrent
Class Timeout

java.lang.Object
  extended by com.atlassian.util.concurrent.Timeout

@Immutable
public class Timeout
extends java.lang.Object

Used to calculate timeouts from when it is created when successively calling blocking methods. Always converts to nanoseconds.

Usage:

 
 


Method Summary
static Timeout getMillisTimeout(long time, java.util.concurrent.TimeUnit unit)
          Get a Timeout that uses nanosecond precision.
static Timeout getNanosTimeout(long time, java.util.concurrent.TimeUnit unit)
          Get a Timeout that uses nanosecond precision.
 long getTime()
           
 java.util.concurrent.TimeUnit getUnit()
           
 boolean isExpired()
          Has this timeout expired
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNanosTimeout

public static Timeout getNanosTimeout(long time,
                                      java.util.concurrent.TimeUnit unit)
Get a Timeout that uses nanosecond precision. The accuracy will depend on the accuracy of System.nanoTime().

Parameters:
time - the maximum time to wait for the lock
unit - the time unit of the time argument.
Returns:
timeout with TimeUnit.NANOSECONDS precision.

getMillisTimeout

public static Timeout getMillisTimeout(long time,
                                       java.util.concurrent.TimeUnit unit)
Get a Timeout that uses nanosecond precision. The accuracy will depend on the accuracy of System.nanoTime().

Parameters:
time - the maximum time to wait for the lock
unit - the time unit of the time argument.
Returns:
timeout with TimeUnit.NANOSECONDS precision.

getTime

public long getTime()

getUnit

public java.util.concurrent.TimeUnit getUnit()

isExpired

public boolean isExpired()
Has this timeout expired

Returns:


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.