orc.runtime
Class TokenPool

java.lang.Object
  extended by orc.runtime.TokenPool

public final class TokenPool
extends java.lang.Object

Implement a token pool to avoid allocating and freeing a lot of tokens.

Author:
quark

Constructor Summary
TokenPool(int bound)
          Create a new pool with the given bound.
 
Method Summary
 void freeToken(Token token)
          Free a token
 Token newToken()
          Create and return a new, uninitialized token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenPool

public TokenPool(int bound)
Create a new pool with the given bound. If bound < 0 then the pool is unlimited.

Method Detail

newToken

public Token newToken()
               throws TokenLimitReachedError
Create and return a new, uninitialized token.

Throws:
TokenLimitReachedError

freeToken

public void freeToken(Token token)
Free a token