Package com.prineside.tdi2.utils
Class SafePools
java.lang.Object
com.prineside.tdi2.utils.SafePools
Thread-safe version of GDX's Pools
Why thread safe:
- Some events (like LogEntryAdd) may be triggered on a different threads
- Multiple gameStates can be simulated on a different threads at the same time
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static interface
static final class
static class
-
Method Summary
Modifier and TypeMethodDescription<T> SafePools.Pool<T>
create
(int initial, int max, ObjectSupplier<T> provider) void
Frees an object from thepool
.void
Frees the specified objects from thepool
.void
Frees the specified objects from thepool
.<T> SafePools.Pool<T>
Returns a new or existing pool for the specified type, stored in a Class toSafePools.Pool
map.<T> SafePools.Pool<T>
static SafePools
<T> T
Obtains an object from thepool
.<T> void
set
(Class<T> type, SafePools.Pool<T> pool) Sets an existing pool for the specified type, stored in a Class toSafePools.Pool
map.
-
Method Details
-
getInstance
-
create
- Returns:
- RegularPool or a simple instantiator depending on the Engine's config
-
get
-
get
Returns a new or existing pool for the specified type, stored in a Class toSafePools.Pool
map. The max size of the pool used is 100. -
set
Sets an existing pool for the specified type, stored in a Class toSafePools.Pool
map. -
obtain
Obtains an object from thepool
. -
free
Frees an object from thepool
. -
freeAll
Frees the specified objects from thepool
. Null objects within the array are silently ignored. Objects don't need to be from the same pool. -
freeAll
Frees the specified objects from thepool
. Null objects within the array are silently ignored.- Parameters:
samePool
- If true, objects don't need to be from the same pool but the pool must be looked up for each object.
-