-_pool = {}
 _setup = null
 _extend = null
 currentFlavour = null
 
+
+createLock = (locks, openDoorFn)->
+  _locks = [].concat locks
+  (lock)->
+    index = _locks.indexOf lock
+    openDoorFn() if !!~index and _locks.splice(index, 1).length and !_locks.length
+
+
 # Helpers to manage the calls to functions defined from the start
 # event if they are not available
+_pool = {}
 createPool = (name)->
   _pool[name]  = {} unless _pool[name]
   _p = _pool[name]


  _hull

# Wraps the failure callback
# * Executes the failure behaviour defined by the current flavour
failureCb = (args...)->
  currentFlavour.failure(args...)
  _setup.userFailureFn(args...)

bootstrap = ()->
  return unless _setup and currentFlavour
  currentFlavour.condition(_setup.config).then(successCb, failureCb)

require ['flavour', 'underscore', 'lib/utils/version'], (flavour, _, version)->
  _hull.version = version
  _extend = _.extend
  currentFlavour = flavour
  bootstrap()


deletePool = (name)->
  delete _pool[name]


# * Checks that it has not been called before
# * Augments coniguration
# * Unlocks the achievement :p
preInit = (config, cb, errb)->
  throw 'Hull.init has already been called' if _setup

