My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.flashdynamix.utils {

public class ObjectPool {

public var minSize : int;
public var size : int = 0;
public var Create : Class;
public var length : int = 0;

private var list : Array = [];
private var disposed : Boolean = false;

public function ObjectPool(Create : Class, minSize : int = 10) {
this.Create = Create;
this.minSize = minSize;

for(var i : int = 0;i < minSize; i++) add();
}

public function add() : void {
list[length++] = new Create();
size++;
}

public function checkOut() : * {
if(length == 0) {
size++;
return new Create();
}

return list[--length];
}

public function checkIn(item : *) : void {
list[length++] = item;
}

public function empty() : void {
size = length = list.length = 0;
}

public function dispose() : void {
if(disposed) return;

disposed = true;

Create = null;
list = null;
}
}
}

Change log

r89 by flashdynamix on Jan 20, 2009   Diff
Update to perform more efficient garbage
collection.
Version number change to 0.2.1
Go to: 
Project members, sign in to write a code review

Older revisions

r81 by flashdynamix on Jan 18, 2009   Diff
Change for naming convention for
useSmartRotate to just smartRotate
r17 by flashdynamix on Jan 3, 2009   Diff
[No log message]
All revisions of this file

File info

Size: 932 bytes, 51 lines
Powered by Google Project Hosting