Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | List of all members
Mezzanine::Threading::DoubleBufferedResource< T > Class Template Reference

A thread specific resource that uses double buffering to avoid multithreaded synchronization mechanisms. More...

#include <doublebufferedresource.h>

Public Member Functions

 DoubleBufferedResource ()
 A Constructor that creates default versions of the resources. More...
 
 DoubleBufferedResource (T *Current, T *Buffer)
 A constructor that takes ownership of the the resources passed. More...
 
 ~DoubleBufferedResource ()
 Destructor, this deletes both the resources managed. Regardless of how it got a hold of the pointers.
 
T & GetCommittable ()
 Get a reference to the resource that can be committed. More...
 
T * GetCommittablePointer () const
 Get a pointer to the resource that can be committed. More...
 
T & GetUsable ()
 Get a reference to the resource that can be used. More...
 
T * GetUsablePointer () const
 Get a pointer to the resource that can be used. More...
 
void SwapUsableAndCommitable ()
 Make the buffered resource the active and vice versa.
 

Detailed Description

template<typename T>
class Mezzanine::Threading::DoubleBufferedResource< T >

A thread specific resource that uses double buffering to avoid multithreaded synchronization mechanisms.

It is intended for a Mezzanine::Threading::iWorkUnit "iWorkUnit" like the to provide asynchronous access to resources that to not need immediate atomicity. For example, it is ok if logs are gathered asynchronously and aggregated later as long no log messages are damaged, lost or taken out of order. This allows IO and other potentially expensive tasks to be used without blocking the current thread.

Definition at line 70 of file doublebufferedresource.h.

Constructor & Destructor Documentation

A Constructor that creates default versions of the resources.

This calls the default constructors for type T.

Definition at line 82 of file doublebufferedresource.h.

template<typename T >
Mezzanine::Threading::DoubleBufferedResource< T >::DoubleBufferedResource ( T *  Current,
T *  Buffer 
)
inline

A constructor that takes ownership of the the resources passed.

Parameters
CurrentThis will be used as the first resource for threads to use.
BufferThis will wait for the other thread

Definition at line 101 of file doublebufferedresource.h.

Member Function Documentation

template<typename T >
T& Mezzanine::Threading::DoubleBufferedResource< T >::GetCommittable ( )
inline

Get a reference to the resource that can be committed.

Returns
A reference to the commitable resource

Definition at line 125 of file doublebufferedresource.h.

template<typename T >
T* Mezzanine::Threading::DoubleBufferedResource< T >::GetCommittablePointer ( ) const
inline

Get a pointer to the resource that can be committed.

Returns
A pointer to the commitable resource

Definition at line 115 of file doublebufferedresource.h.

template<typename T >
T& Mezzanine::Threading::DoubleBufferedResource< T >::GetUsable ( )
inline

Get a reference to the resource that can be used.

Returns
A reference to the usable resource

Definition at line 120 of file doublebufferedresource.h.

template<typename T >
T* Mezzanine::Threading::DoubleBufferedResource< T >::GetUsablePointer ( ) const
inline

Get a pointer to the resource that can be used.

Returns
A pointer to the usable resource

Definition at line 110 of file doublebufferedresource.h.


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