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.
Public Member Functions | |
---|---|
RShBuf () | |
IMPORT_C TInt | Alloc ( RShPool &, TUint ) |
IMPORT_C void | Close () |
IMPORT_C TInt | Map ( TBool ) |
IMPORT_C TUint8 * | Ptr () |
IMPORT_C TUint | Size () |
IMPORT_C TInt | UnMap () |
Inherited Enumerations | |
---|---|
RHandleBase:TAttributes |
Private Attributes | |
---|---|
TLinAddr | iBase |
TUint | iSize |
TUint | iSpare1 |
TUint | iSpare2 |
Inherited Attributes | |
---|---|
RHandleBase::iHandle |
IMPORT_C TInt | Alloc | ( | RShPool & | aPool, |
TUint | aFlags = 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.
IMPORT_C void | Close | ( | ) |
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.
IMPORT_C TInt | Map | ( | TBool | aReadOnly = 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.
TBool aReadOnly = EFalse | Indicates whether the buffer should be mapped as read-only. The default is that of pool in the clients address space. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.