ioio.lib.impl
Class ModuleAllocator

java.lang.Object
  extended by ioio.lib.impl.ModuleAllocator

public class ModuleAllocator
extends java.lang.Object

Utility to allocate and assign unique module ids. A module id is requested via allocateModule() and released via releaseModule(int).

Author:
birmiwal

Constructor Summary
ModuleAllocator(java.util.Collection<java.lang.Integer> availableModuleIds, java.lang.String name)
           
ModuleAllocator(int[] availableModuleIds, java.lang.String name)
           
ModuleAllocator(int maxModules, java.lang.String name)
           
 
Method Summary
 java.lang.Integer allocateModule()
           
 void releaseModule(int moduleId)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleAllocator

public ModuleAllocator(java.util.Collection<java.lang.Integer> availableModuleIds,
                       java.lang.String name)

ModuleAllocator

public ModuleAllocator(int[] availableModuleIds,
                       java.lang.String name)

ModuleAllocator

public ModuleAllocator(int maxModules,
                       java.lang.String name)
Method Detail

allocateModule

public java.lang.Integer allocateModule()
Returns:
a module id that was allocated, or null if nothing was available

releaseModule

public void releaseModule(int moduleId)
Parameters:
moduleId - the moduleId to be released; throws IllegalArgumentException if a moduleId is re-returned, or an invalid moduleId is provided