 
         @worker = worker or @processTask
 
+        if @concurrency <= 0
+            throw new Error "Invalid initialization parameters"
+
         @queue =
             head: null
             tail: null

        @slots = []

        for i in [0 .. @concurrency - 1]
            @indices[i] = -1
            @slots.push i

    @getter "waiting", -> @queue.length

                try
                    tasklet.callback? error, data
                catch cbex
                    @emit "callback exception", tasklet.task, cbex

                @indices[slot] = null
                @slots.push slot
                @scheduleEventLoop()
        catch ex
            @emit "error", tasklet.task, ex
            try
                tasklet.callback? ex
            catch cbex
                @emit "callback exception", tasklet.task, cbex

            @indices[slot] = null
            @slots.push slot
            @scheduleEventLoop()

    processTask: (task, callback) ->
        callback? null


module.exports = AsyncWorkQueue
