XLE  v0.02.0
Public Member Functions | Friends | List of all members
RenderCore::SharedPkt Class Reference

A reference counted packet for small allocations More...

#include <RenderUtils.h>

Inheritance diagram for RenderCore::SharedPkt:
Inheritance graph
[legend]

Public Member Functions

void * get () const never_throws
 
 operator bool () const never_throws
 
void * begin ()
 
void * end ()
 
const void * begin () const
 
const void * end () const
 
size_t size () const
 
 SharedPkt (const SharedPkt &cloneFrom)
 
SharedPktoperator= (const SharedPkt &cloneFrom)
 
 SharedPkt (SharedPkt &&moveFrom) never_throws
 
SharedPktoperator= (SharedPkt &&moveFrom) never_throws
 
void swap (SharedPkt &other) never_throws
 
- Public Member Functions inherited from Utility::MiniHeap::Allocation
 operator void * ()
 
 operator bool ()
 
template<typename Type >
 operator Type ()
 
 Allocation (void *a, uint32 marker)
 

Friends

SharedPkt MakeSharedPktSize (size_t size)
 
SharedPkt MakeSharedPkt (const void *begin, const void *end)
 

Additional Inherited Members

- Public Attributes inherited from Utility::MiniHeap::Allocation
void * _allocation
 
uint32 _marker
 

Detailed Description

A reference counted packet for small allocations

This object manage a small packet of reference counted memory in a way that reduces fragmentation and contention for the main heap.

Often we need to create small packets for constant buffer uploads. We want those packets to be variable sized (but typically multiples of 8), and have reference counting attached. Most of the time the allocations might be created and destroyed during a single frame (but sometimes the allocations can last longer).

This object uses a dedicated heap that is designed to deal with many small constant-buffer sized packets. It performs thread safe reference counting, so packets can be passed between threads safely.

By using a separate heap, we avoid polluting the main heap with these smaller (often short-lived) allocations.

SharedPkt has proper value semantics (it works like a smart pointer, but with a size attached). Prefer to use the "move" type methods to avoid unnecessary AddRef/Releases.


The documentation for this class was generated from the following files: