diff -r 51a74ef9ed63 -r ae94777fff8f Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita --- a/Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita Wed Mar 31 11:11:55 2010 +0100 +++ b/Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita Fri Jun 11 12:39:03 2010 +0100 @@ -1,49 +1,49 @@ - - - - - -Data Access ExampleThis example describes typical processing of the data in an RMBufChain.
Downwards flow - Example : flow going downwards -

The following function is a simplified example of how a component in the middle of the stack could process data sent to the driver. As shown in the above diagram, the upper layer provides the data in the RMBufChain parameter.

-void Send (RMBufChain &aChain) -{ - TBuf8<KHeaderLength> aHeader; - - // [...] fill the header - - // request space in front of the data - aChain.Prepend(KHeaderLength); - - // add the protocol header - aChain.CopyIn(aHeader); - - // send the updated chain to the next layer - downwardComponent->Send(aChain); -} -

Note that depending on the available space remaining in front of the data in the MBuf, the RMBufChain::Prepend() method may request the pond to add a new MBuf to the front of the chain. For more information, see Buffer layout.

Upwards flow - Example : flow going upwards -

The following function is a simplified example of how a component in the middle of the stack could process data received by the driver. As shown in the above diagram, the underlying layer provides the data in the RMBufChain parameter.

-void Process (RMBufChain &aChain) -{ - TBuf8<KHeaderLength> aHeader; - - // get a copy of the header - aChain.CopyOut(KHeaderLength, &aHeader); - - // discard the header in the chain - aChain.TrimStart(KHeaderLength); - - // [...] process the header - - // send the updated chain to the next layer - appropriateUpwardComponent->Process(aChain); -} -

Note that the header might not be stored in a contiguous memory area: it can be splitted accross several chained MBufs. For a better performance, you should define a buffer size slightly bigger than your MTU: for more information, see Pond Configuration : Recommendations.

Overview Comms Buffers (MBuf) + + + + + +Data Access ExampleThis example describes typical processing of the data in an RMBufChain.
Downwards flow + Example : flow going downwards +

The following function is a simplified example of how a component in the middle of the stack could process data sent to the driver. As shown in the above diagram, the upper layer provides the data in the RMBufChain parameter.

+void Send (RMBufChain &aChain) +{ + TBuf8<KHeaderLength> aHeader; + + // [...] fill the header + + // request space in front of the data + aChain.Prepend(KHeaderLength); + + // add the protocol header + aChain.CopyIn(aHeader); + + // send the updated chain to the next layer + downwardComponent->Send(aChain); +} +

Note that depending on the available space remaining in front of the data in the MBuf, the RMBufChain::Prepend() method may request the pond to add a new MBuf to the front of the chain. For more information, see Buffer layout.

Upwards flow + Example : flow going upwards +

The following function is a simplified example of how a component in the middle of the stack could process data received by the driver. As shown in the above diagram, the underlying layer provides the data in the RMBufChain parameter.

+void Process (RMBufChain &aChain) +{ + TBuf8<KHeaderLength> aHeader; + + // get a copy of the header + aChain.CopyOut(KHeaderLength, &aHeader); + + // discard the header in the chain + aChain.TrimStart(KHeaderLength); + + // [...] process the header + + // send the updated chain to the next layer + appropriateUpwardComponent->Process(aChain); +} +

Note that the header might not be stored in a contiguous memory area: it can be splitted accross several chained MBufs. For a better performance, you should define a buffer size slightly bigger than your MTU: for more information, see Pond Configuration : Recommendations.

Overview Comms Buffers (MBuf) and Comms Chains
\ No newline at end of file