Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Static Public Member Functions | Private Attributes
cat::AsyncBuffer Class Reference

#include <AsyncBuffer.hpp>

List of all members.

Public Member Functions

CAT_INLINE bool Call (ThreadPoolLocalStorage *tls, int error, AsyncBuffer *buffer, u32 bytes)
template<class T >
CAT_INLINE TGetData ()
template<class T >
CAT_INLINE TGetData (T *&ptr)
CAT_INLINE u8GetData ()
CAT_INLINE u32 GetDataBytes ()
CAT_INLINE u64 GetOffset ()
CAT_INLINE AsyncOv * GetOv ()
template<class T >
CAT_INLINE TGetTag ()
template<class T >
CAT_INLINE TGetTag (T *&ptr)
CAT_INLINE u32 GetTagBytes ()
CAT_INLINE u8GetTagData ()
CAT_INLINE void Release ()
CAT_INLINE void Reset (const AsyncCallback &callback, u64 offset=0)
CAT_INLINE AsyncBufferResize (u32 data_bytes)
CAT_INLINE void Zero ()

Static Public Member Functions

static CAT_INLINE AsyncBufferAcquire (AsyncBuffer *&ptr, u32 data_bytes=0, u32 tag_bytes=0)
template<class T >
static CAT_INLINE TAcquire (T *&data, u32 tag_bytes=0)
static CAT_INLINE u8Acquire (u32 data_bytes=0, u32 tag_bytes=0)
static CAT_INLINE u32 OVERHEAD ()
static CAT_INLINE AsyncBufferPromote (void *vdata)
static CAT_INLINE void Release (AsyncBuffer *buffer)
static CAT_INLINE void Release (void *vdata)
static CAT_INLINE u8Resize (void *vdata, u32 data_bytes)
static CAT_INLINE AsyncBufferWrap (void *vdata, u32 data_bytes, u32 tag_bytes=0)

Private Attributes

AsyncCallback _callback
u8_data
u32 _data_bytes
AsyncOv _ov
u8 _tag [1]
u32 _tag_bytes

Detailed Description

Definition at line 62 of file AsyncBuffer.hpp.


Member Function Documentation

static CAT_INLINE AsyncBuffer* cat::AsyncBuffer::Acquire ( AsyncBuffer *&  ptr,
u32  data_bytes = 0,
u32  tag_bytes = 0 
) [inline, static]

Definition at line 128 of file AsyncBuffer.hpp.

References _data, _data_bytes, _tag, _tag_bytes, cat::RegionAllocator::Acquire(), and cat::Singleton< RegionAllocator >::ii.

Referenced by Acquire(), and Resize().

    {
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        AsyncBuffer *buffer = reinterpret_cast<AsyncBuffer*>(
            RegionAllocator::ii->Acquire(OVERHEAD_BYTES + data_bytes + tag_bytes) );

        if (!buffer) return 0;

        buffer->_data_bytes = data_bytes;
        buffer->_tag_bytes = tag_bytes;
        buffer->_data = buffer->_tag + tag_bytes;

        return (ptr = buffer);
    }
static CAT_INLINE u8* cat::AsyncBuffer::Acquire ( u32  data_bytes = 0,
u32  tag_bytes = 0 
) [inline, static]

Definition at line 164 of file AsyncBuffer.hpp.

References _data, and Acquire().

    {
        AsyncBuffer *buffer;

        if (!Acquire(buffer, data_bytes, tag_bytes)) return 0;

        return buffer->_data;
    }
template<class T >
static CAT_INLINE T* cat::AsyncBuffer::Acquire ( T *&  data,
u32  tag_bytes = 0 
) [inline, static]

Definition at line 175 of file AsyncBuffer.hpp.

References _data, Acquire(), and T.

    {
        AsyncBuffer *buffer;

        if (!Acquire(buffer, sizeof(T), tag_bytes)) return 0;

        return (data = reinterpret_cast<T*>( buffer->_data ));
    }
CAT_INLINE bool cat::AsyncBuffer::Call ( ThreadPoolLocalStorage tls,
int  error,
AsyncBuffer buffer,
u32  bytes 
) [inline]

Definition at line 93 of file AsyncBuffer.hpp.

References _callback.

    {
        if (!_callback) return true;
        return _callback(tls, error, buffer, bytes);
    }
template<class T >
CAT_INLINE T* cat::AsyncBuffer::GetData ( ) [inline]

Definition at line 110 of file AsyncBuffer.hpp.

References _data, and T.

{ return reinterpret_cast<T*>( _data ); }
CAT_INLINE u8* cat::AsyncBuffer::GetData ( ) [inline]

Definition at line 107 of file AsyncBuffer.hpp.

References _data.

{ return reinterpret_cast<u8*>( _data ); }
template<class T >
CAT_INLINE T* cat::AsyncBuffer::GetData ( T *&  ptr) [inline]

Definition at line 113 of file AsyncBuffer.hpp.

References _data.

{ return (ptr = reinterpret_cast<T*>( _data )); }
CAT_INLINE u32 cat::AsyncBuffer::GetDataBytes ( ) [inline]

Definition at line 105 of file AsyncBuffer.hpp.

References _data_bytes.

{ return _data_bytes; }
CAT_INLINE u64 cat::AsyncBuffer::GetOffset ( ) [inline]

Definition at line 91 of file AsyncBuffer.hpp.

References _ov.

{ return ((u64)_ov.OffsetHigh << 32) | _ov.Offset; }
CAT_INLINE AsyncOv* cat::AsyncBuffer::GetOv ( ) [inline]

Definition at line 90 of file AsyncBuffer.hpp.

References _ov.

{ return &_ov; }
template<class T >
CAT_INLINE T* cat::AsyncBuffer::GetTag ( ) [inline]

Definition at line 121 of file AsyncBuffer.hpp.

References _tag, and T.

{ return reinterpret_cast<T*>( _tag ); }
template<class T >
CAT_INLINE T* cat::AsyncBuffer::GetTag ( T *&  ptr) [inline]

Definition at line 124 of file AsyncBuffer.hpp.

References _tag.

{ return (ptr = reinterpret_cast<T*>( _tag )); }
CAT_INLINE u32 cat::AsyncBuffer::GetTagBytes ( ) [inline]

Definition at line 116 of file AsyncBuffer.hpp.

References _tag_bytes.

{ return _tag_bytes; }
CAT_INLINE u8* cat::AsyncBuffer::GetTagData ( ) [inline]

Definition at line 118 of file AsyncBuffer.hpp.

References _tag.

{ return _tag; }
static CAT_INLINE u32 cat::AsyncBuffer::OVERHEAD ( ) [inline, static]

Definition at line 88 of file AsyncBuffer.hpp.

References _tag.

{ return (u32)(offsetof(AsyncBuffer, _tag)); }
static CAT_INLINE AsyncBuffer* cat::AsyncBuffer::Promote ( void *  vdata) [inline, static]

Definition at line 226 of file AsyncBuffer.hpp.

References _tag.

    {
        u8 *data = reinterpret_cast<u8*>( vdata );
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        if (!data) return 0;
        return reinterpret_cast<AsyncBuffer*>( data - OVERHEAD_BYTES );
    }
static CAT_INLINE void cat::AsyncBuffer::Release ( AsyncBuffer buffer) [inline, static]

Definition at line 241 of file AsyncBuffer.hpp.

References cat::Singleton< RegionAllocator >::ii, and cat::RegionAllocator::Release().

    {
        RegionAllocator::ii->Release(buffer);
    }
CAT_INLINE void cat::AsyncBuffer::Release ( ) [inline]

Definition at line 237 of file AsyncBuffer.hpp.

References cat::Singleton< RegionAllocator >::ii, and cat::RegionAllocator::Release().

    {
        RegionAllocator::ii->Release(this);
    }
static CAT_INLINE void cat::AsyncBuffer::Release ( void *  vdata) [inline, static]

Definition at line 245 of file AsyncBuffer.hpp.

References _tag, cat::Singleton< RegionAllocator >::ii, and cat::RegionAllocator::Release().

    {
        u8 *data = reinterpret_cast<u8*>( vdata );
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        if (!data) return;

        AsyncBuffer *buffer = reinterpret_cast<AsyncBuffer*>( data - OVERHEAD_BYTES );

        RegionAllocator::ii->Release(buffer);
    }
CAT_INLINE void cat::AsyncBuffer::Reset ( const AsyncCallback callback,
u64  offset = 0 
) [inline]

Definition at line 73 of file AsyncBuffer.hpp.

References _callback, and _ov.

    {
#if defined(CAT_OS_WINDOWS)
        _ov.hEvent = 0;
        _ov.Internal = 0;
        _ov.InternalHigh = 0;
        _ov.OffsetHigh = (u32)(offset >> 32);
        _ov.Offset = (u32)offset;
#else
#error "TODO"
#endif
        _callback = callback;
    }
CAT_INLINE AsyncBuffer* cat::AsyncBuffer::Resize ( u32  data_bytes) [inline]

Definition at line 146 of file AsyncBuffer.hpp.

References _data, _data_bytes, _tag, _tag_bytes, cat::Singleton< RegionAllocator >::ii, and cat::RegionAllocator::Resize().

    {
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        AsyncBuffer *buffer = reinterpret_cast<AsyncBuffer*>(
            RegionAllocator::ii->Resize( this,
            OVERHEAD_BYTES + _tag_bytes + data_bytes) );

        if (!buffer) return 0;

        buffer->_data_bytes = data_bytes;
        buffer->_data = buffer->_tag + buffer->_tag_bytes;

        return buffer;
    }
static CAT_INLINE u8* cat::AsyncBuffer::Resize ( void *  vdata,
u32  data_bytes 
) [inline, static]

Definition at line 186 of file AsyncBuffer.hpp.

References _data, _data_bytes, _tag, _tag_bytes, Acquire(), cat::Singleton< RegionAllocator >::ii, and cat::RegionAllocator::Resize().

    {
        u8 *data = reinterpret_cast<u8*>( vdata );
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        if (!data) return Acquire(data_bytes);

        AsyncBuffer *buffer = reinterpret_cast<AsyncBuffer*>( data - OVERHEAD_BYTES );

        buffer = reinterpret_cast<AsyncBuffer*>(
            RegionAllocator::ii->Resize(buffer,
            OVERHEAD_BYTES + buffer->_tag_bytes + data_bytes) );

        if (!buffer) return 0;

        buffer->_data_bytes = data_bytes;

        return (buffer->_data = buffer->_tag + buffer->_tag_bytes);
    }
static CAT_INLINE AsyncBuffer* cat::AsyncBuffer::Wrap ( void *  vdata,
u32  data_bytes,
u32  tag_bytes = 0 
) [inline, static]

Definition at line 208 of file AsyncBuffer.hpp.

References _data, _data_bytes, _tag, _tag_bytes, cat::RegionAllocator::Acquire(), and cat::Singleton< RegionAllocator >::ii.

    {
        u8 *data = reinterpret_cast<u8*>( vdata );
        const u32 OVERHEAD_BYTES = (u32)(offsetof(AsyncBuffer, _tag));

        AsyncBuffer *buffer = reinterpret_cast<AsyncBuffer*>(
            RegionAllocator::ii->Acquire(OVERHEAD_BYTES + tag_bytes) );

        if (!buffer) return 0;

        buffer->_data_bytes = data_bytes;
        buffer->_tag_bytes = tag_bytes;
        buffer->_data = data;
        return buffer;
    }
CAT_INLINE void cat::AsyncBuffer::Zero ( ) [inline]

Definition at line 99 of file AsyncBuffer.hpp.

References _data, _data_bytes, and CAT_CLR.


Member Data Documentation

Definition at line 66 of file AsyncBuffer.hpp.

Referenced by Call(), and Reset().

Definition at line 67 of file AsyncBuffer.hpp.

Referenced by Acquire(), GetData(), Resize(), Wrap(), and Zero().

Definition at line 68 of file AsyncBuffer.hpp.

Referenced by Acquire(), GetDataBytes(), Resize(), Wrap(), and Zero().

AsyncOv cat::AsyncBuffer::_ov [private]

Definition at line 65 of file AsyncBuffer.hpp.

Referenced by GetOffset(), GetOv(), and Reset().

u8 cat::AsyncBuffer::_tag[1] [private]

Definition at line 69 of file AsyncBuffer.hpp.

Referenced by Acquire(), GetTag(), GetTagData(), OVERHEAD(), Promote(), Release(), Resize(), and Wrap().

Definition at line 68 of file AsyncBuffer.hpp.

Referenced by Acquire(), GetTagBytes(), Resize(), and Wrap().


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net