direct.showbase.Pool
from direct.showbase.Pool import Pool
Pool is a collection of python objects that you can checkin and
checkout. This is useful for a cache of objects that are expensive to load
and can be reused over and over, like splashes on cannonballs, or
bulletholes on walls. The pool is unsorted. Items do not have to be unique
or be the same type.
Internally the pool is implemented with 2 lists, free items and used items.
Example
p = Pool ([ 1 , 2 , 3 , 4 , 5 ])
x = p . checkout ()
p . checkin ( x )
Inheritance diagram
Inheritance diagram of direct.showbase.Pool
class Pool
( free = None ) [source]
Bases: object
__init__
( self , free = None ) [source]
add
( self , item ) [source]
Add an item to the free list.
checkin
( self , item ) [source]
Put back a checked out item.
Error if the item is not checked out.
checkout
( self ) [source]
Get an arbitrary item from the pool.
cleanup
( self , cleanupFunc = None ) [source]
Completely cleanup the pool and all of its objects.
cleanupFunc will be called on every free and used item.
getNumItems
( self ) [source]
Returns the number of free items and the number of used items.
hasFree
( self ) [source]
Returns true if there is at least one free item.
isFree
( self , item ) [source]
Returns true if this item is free for check out.
isUsed
( self , item ) [source]
Returns true if this item has already been checked out.
notify
= <direct.directnotify.Notifier.Notifier object>
remove
( self , item ) [source]
Remove an item. Error is flagged if the item is not in the pool.
reset
( self ) [source]
Resets the pool so all items are free.