RShBuf Class Reference

class RShBuf : public RHandleBase

A handle to a shared buffer within a pool.

A user-side or kernel-side component allocates the buffer and then passes the handle to the recipient.

Upon receiving a buffer handle. the recipient may map the buffer memory into its address space if not already done so.

When finished with the buffer, the recipient must Close() the handle. This invalidates the handle; any further attempt to use it will panic the thread.

Buffers are reference-counted and will only be freed and returned to the pool when all users have closed them.

These handles are process-relative.

Inherits from

Constructor & Destructor Documentation

RShBuf()

RShBuf()[inline]

Member Functions Documentation

Alloc(RShPool &, TUint)

IMPORT_C TIntAlloc(RShPool &aPool,
TUintaFlags = 0
)

Allocates a shared data buffer.

By default this method will return immediately with KErrNoMemory if no buffer is available on the pool's free list, even if the pool could grow automatically.

By default it will also map the allocated buffer into the calling process's address space.

Setting EShPoolAllocCanWait in the flags indicates that the caller is prepared to wait while the pool is grown if a buffer is not immediately available on the free list.

Setting EShPoolAllocNoMap in the flags indicates that the caller does not want the buffer to be automatically mapped into its address space. This can improve performance on buffers from page-aligned pools if the caller will not need to access the data in the buffer (e.g. if it will just be passing it on to another component). This only prevents mapping if the pool is set to not automatically map buffers into processes' address space.

TShPoolAllocFlags

Parameters

RShPool & aPoolPool handle
TUint aFlags = 0Bitwise OR of values from TShPoolAllocFlags to specify non-default behaviour.

Close()

IMPORT_C voidClose()

Closes the handle.

This has the effect of closing the associated kernel side object.

As the associated object is a reference counting object, it is destroyed if there are no other open references to it.

CObject

Map(TBool)

IMPORT_C TIntMap(TBoolaReadOnly = EFalse)

Maps the buffer into the calling process's virtual address space if not already done.

It is not necessary to call this method on buffers from non-page-aligned pools, although it will cause no harm to do so (and will result in KErrNone being returned).

It is not necessary to call this method on buffers from page-aligned pools returned by Alloc() unless EShPoolAllocNoMap was specified.

Parameters

TBool aReadOnly = EFalseIndicates whether the buffer should be mapped as read-only. The default is that of pool in the clients address space.

Ptr()

IMPORT_C TUint8 *Ptr()

Size()

IMPORT_C TUintSize()

UnMap()

IMPORT_C TIntUnMap()

Unmaps the buffer from the calling process's virtual address space.

Member Data Documentation

TLinAddr iBase

TLinAddr iBase[private]

TUint iSize

TUint iSize[private]

TUint iSpare1

TUint iSpare1[private]

TUint iSpare2

TUint iSpare2[private]