Panda3D
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Member Functions
SimpleLru Class Reference

An implementation of a very simple LRU algorithm. More...

Inheritance diagram for SimpleLru:
LinkedListNode Namable

List of all members.

Public Member Functions

 SimpleLru (string name, unsigned int max_size)
 beginEpoch ()
 Marks the end of the previous epoch and the beginning of the next one.
 considerEvict ()
 Evicts a sequence of objects if the queue is full.
unsigned int countActiveSize ()
 Returns the total size of the pages that were enqueued since the last call to begin_epoch().
 evictTo (unsigned int target_size)
 Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size.
unsigned int getMaxSize ()
 Returns the max size of all objects that are allowed to be active on the LRU.
unsigned int getTotalSize ()
 Returns the total size of all objects currently active on the LRU.
 output (ostream out)
 Outputs the Namable.
 setMaxSize (unsigned int max_size)
 Changes the max size of all objects that are allowed to be active on the LRU.
bool validate ()
 Checks that the LRU is internally self-consistent.
 write (ostream out, int indent_level)

Detailed Description

An implementation of a very simple LRU algorithm.

Also see AdaptiveLru.


Constructor & Destructor Documentation

SimpleLru ( string  name,
unsigned int  max_size 
)

Member Function Documentation

Marks the end of the previous epoch and the beginning of the next one.

This will evict any objects that are pending eviction, and also update any internal bookkeeping.

Evicts a sequence of objects if the queue is full.

unsigned int countActiveSize ( )

Returns the total size of the pages that were enqueued since the last call to begin_epoch().

evictTo ( unsigned int  target_size)

Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size.

unsigned int getMaxSize ( )

Returns the max size of all objects that are allowed to be active on the LRU.

unsigned int getTotalSize ( )

Returns the total size of all objects currently active on the LRU.

output ( ostream  out)

Outputs the Namable.

This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

Reimplemented from Namable.

setMaxSize ( unsigned int  max_size)

Changes the max size of all objects that are allowed to be active on the LRU.

If the size is (size_t)-1, there is no limit.

bool validate ( )

Checks that the LRU is internally self-consistent.

Returns true if successful, false if there is some problem.

write ( ostream  out,
int  indent_level 
)
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties