Panda3D
|
One atomic piece that may be managed by a SimpleLru chain. More...
#include "simpleLru.h"
Public Member Functions | |
SimpleLruPage (size_t lru_size) | |
SimpleLruPage (const SimpleLruPage ©) | |
void | dequeue_lru () |
Removes the page from its SimpleLru. | |
void | enqueue_lru (SimpleLru *lru) |
Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added. | |
virtual void | evict_lru () |
Evicts the page from the LRU. | |
SimpleLru * | get_lru () const |
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU. | |
size_t | get_lru_size () const |
Returns the size of this page as reported to the LRU, presumably in bytes. | |
void | mark_used_lru () const |
To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on. | |
void | mark_used_lru (SimpleLru *lru) |
To be called when the page is used; this will move it to the tail of the specified SimpleLru queue. | |
void | operator= (const SimpleLruPage ©) |
virtual void | output (ostream &out) const |
void | set_lru_size (size_t lru_size) |
Specifies the size of this page, presumably in bytes, although any unit is possible. | |
virtual void | write (ostream &out, int indent_level) const |
Protected Member Functions | |
void | insert_after (LinkedListNode *node) |
Adds a LinkedListNode record after the indicated node in the doubly-linked list. | |
void | insert_before (LinkedListNode *node) |
Adds a LinkedListNode record before the indicated node in the doubly-linked list. | |
bool | is_on_list () const |
Returns true if the node is member of any list, false if it has been removed or never added. | |
void | remove_from_list () |
Removes a LinkedListNode record from the doubly-linked list. | |
void | take_list_from (LinkedListNode *other_root) |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list. | |
Protected Attributes | |
LinkedListNode * | _next |
LinkedListNode * | _prev |
Friends | |
class | SimpleLru |
One atomic piece that may be managed by a SimpleLru chain.
To use this class, inherit from it and override evict_lru().
Definition at line 70 of file simpleLru.h.
void SimpleLruPage::dequeue_lru | ( | ) | [inline] |
Removes the page from its SimpleLru.
Definition at line 164 of file simpleLru.I.
References LinkedListNode::remove_from_list().
Referenced by evict_lru(), and GeomVertexArrayData::evict_lru().
void SimpleLruPage::enqueue_lru | ( | SimpleLru * | lru | ) |
Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added.
If lru is NULL, it means to remove this page from its LRU.
Definition at line 70 of file simpleLru.cxx.
References LinkedListNode::insert_before(), and LinkedListNode::remove_from_list().
Referenced by SimpleLru::begin_epoch(), and mark_used_lru().
void SimpleLruPage::evict_lru | ( | ) | [virtual] |
Evicts the page from the LRU.
Called internally when the LRU determines that it is full. May also be called externally when necessary to explicitly evict the page.
It is legal for this method to either evict the page as requested, do nothing (in which case the eviction will be requested again at the next epoch), or requeue itself on the tail of the queue (in which case the eviction will be requested again much later).
Reimplemented in GeomVertexArrayData, and VertexDataPage.
Definition at line 255 of file simpleLru.cxx.
References dequeue_lru().
SimpleLru * SimpleLruPage::get_lru | ( | ) | const [inline] |
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.
Definition at line 153 of file simpleLru.I.
size_t SimpleLruPage::get_lru_size | ( | ) | const [inline] |
Returns the size of this page as reported to the LRU, presumably in bytes.
Definition at line 208 of file simpleLru.I.
void LinkedListNode::insert_after | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record after the indicated node in the doubly-linked list.
Definition at line 108 of file linkedListNode.I.
void LinkedListNode::insert_before | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record before the indicated node in the doubly-linked list.
Definition at line 91 of file linkedListNode.I.
Referenced by SimpleAllocator::do_alloc(), AdaptiveLru::do_partial_lru_update(), and enqueue_lru().
bool LinkedListNode::is_on_list | ( | ) | const [inline, protected, inherited] |
Returns true if the node is member of any list, false if it has been removed or never added.
The head of a list generally appears to to always be a member of itself.
Definition at line 62 of file linkedListNode.I.
void SimpleLruPage::mark_used_lru | ( | SimpleLru * | lru | ) | [inline] |
To be called when the page is used; this will move it to the tail of the specified SimpleLru queue.
Definition at line 197 of file simpleLru.I.
References enqueue_lru().
void SimpleLruPage::mark_used_lru | ( | ) | const [inline] |
To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on.
This method is const because it's not technically modifying the contents of the page itself.
Definition at line 184 of file simpleLru.I.
Referenced by VertexDataPage::get_page_data(), and GeomVertexArrayData::operator=().
void LinkedListNode::remove_from_list | ( | ) | [inline, protected, inherited] |
Removes a LinkedListNode record from the doubly-linked list.
Definition at line 73 of file linkedListNode.I.
Referenced by dequeue_lru(), SimpleAllocatorBlock::do_free(), AdaptiveLru::do_partial_lru_update(), and enqueue_lru().
void SimpleLruPage::set_lru_size | ( | size_t | lru_size | ) | [inline] |
Specifies the size of this page, presumably in bytes, although any unit is possible.
Definition at line 219 of file simpleLru.I.
void LinkedListNode::take_list_from | ( | LinkedListNode * | other_root | ) | [inline, protected, inherited] |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list.
Definition at line 127 of file linkedListNode.I.
Referenced by BufferContextChain::take_from().