Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Replace this function with your "new" function
- local function NewItem()
- return { }
- end
- -- Storage of released items
- local pool = {}
- -- Get/create a new item
- local function Acquire()
- local item = next(pool)
- if not item then
- item = NewItem()
- else
- pool[item] = nil
- end
- return item
- end
- -- Release an item to the pool
- local function Release(item)
- if pool[item] then
- error("Attempt to release a item that was already released")
- end
- pool[item] = true
- end
Add Comment
Please, Sign In to add comment