Symbian3/SDK/Source/GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C" xml:lang="en"><title>MessageQueue
       
    13 Example</title><shortdesc>This example application shows the use of message queue in interprocess
       
    14 communication using the RMsgQueue class.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <section id="GUID-ED679CA7-FF4C-4E69-8663-5DA46A3D94F4"><title>Download</title> <p>Click
       
    16 on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-d72e85ad-4659-4f66-9cb3-f084e9505709.zip" scope="external">MessageQueueExample.zip</xref>.</p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-d72e85ad-4659-4f66-9cb3-f084e9505709.html" scope="peer">browse</xref> to view the example code.</p> </section>
       
    17 <section id="GUID-39D2064D-AD24-4785-956F-18A0CAD57B81"><title>Description</title> <p>The
       
    18 example describes the global message queue. The following sections provide
       
    19 more information. </p> <p><b> MessageQueueExample</b> </p> <p>The example
       
    20 comprises two processes: a Collector, which collects words from the user via
       
    21 the console, and an Inverter, which periodically reverses the order of the
       
    22 collected words. The Collector and the Inverter pass words to each other using
       
    23 two message queues: InverterInQ and InverterOutQ. The Collector is the main
       
    24 process which starts the Inverter process. The Collector process takes user
       
    25 input in form of different words and sends to the Inverter process via message
       
    26 queue. The Inverter process receives messages at a regular interval of 10
       
    27 seconds, inverts the words in the message and sends it back to the Collector. </p> <p>The
       
    28 Collector creates an active object to collect words from the user and another
       
    29 active object to receive words from the Inverter. Each active object has its
       
    30 own console for display. More information about running the example is given
       
    31 in the build section of this document. </p> <p><b>Design</b> </p> <p>The following
       
    32 block diagram describes the example in more detail. </p> <fig id="GUID-27A0C389-EDDD-5E17-82EE-2727F21803AF">
       
    33 <image href="GUID-CD7F507C-CDD5-5612-BA1B-72641D28FA4A_d0e257906_href.png" placement="inline"/>
       
    34 </fig><p><filepath>CCollector.exe</filepath> is the Collector process. The
       
    35 user starts the Collector and creates an active scheduler and two global message
       
    36 queues. It also starts the Inverter process called <filepath>Inverter.exe</filepath>.
       
    37 The Collector creates one active object to collect words from the user and
       
    38 another active object to monitor its input queue (InverterOutQ). The active
       
    39 object to collect words is an object of class CCollector and the active object
       
    40 which monitors <codeph>InverterOutQ</codeph> is an object of class <xref href="GUID-A39BC295-2845-3018-B8B8-49418277E7EB.dita"><apiname>CMsgQActive</apiname></xref>.
       
    41 The two active objects have different consoles (one for user input and one
       
    42 for displaying the output message). </p><p> The user inputs words in the console.
       
    43 The set of words goes to the <codeph>InverterInQ</codeph> when the "<codeph>Enter</codeph>"
       
    44 key is pressed. If the "<codeph>ESC</codeph>" key is pressed, the system stops
       
    45 and sends the command to the Inverter process to stop.</p><p> The Inverter
       
    46 is another process which opens the global message queues. It creates an active
       
    47 scheduler and implements a periodic timer. The timer wakes every 10 seconds
       
    48 to receive the words from the <codeph>InverterInQ</codeph>. It also checks
       
    49 for a stop command, which closes the message queue and the two process. The
       
    50 Inverter inverts the received words and sends the result to <codeph>InverterOutQ</codeph>. </p><p>In
       
    51 the Collector process, the active object that monitors the <codeph>InveterOutQ</codeph> opens
       
    52 the message queue, receives the received words and displays  them in its console.
       
    53 It uses the <xref href="GUID-6E6B3CD0-FB61-336D-9357-2FFBE3F7A57A.dita"><apiname>NotifyDataAvailable()</apiname></xref> API to monitor the queue
       
    54 for the next set of data. </p><p>The Class diagram of the example is shown
       
    55 below </p><fig id="GUID-E93EF1D6-1B9D-4C76-80B0-1FF660B5C75A">
       
    56 <image href="GUID-3560E862-CB68-584F-B9B6-FCD9F0D202DC_d0e257954_href.png" placement="inline"/>
       
    57 </fig> </section>
       
    58 <section id="GUID-86B04D06-7046-49BD-AE1A-57D5E406F864"><title>Class summary</title><ul>
       
    59 <li><p> <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> - Periodic timer active object.</p></li>
       
    60 <li><p><xref href="GUID-5195B8D1-851E-3BEE-A72D-1841C0937300.dita"><apiname> RMsgQueue</apiname></xref> - A handle to a message queue.</p></li>
       
    61 <li><p><xref href="GUID-9DD1EA2B-DC59-315C-8E9C-CE6D9461B695.dita"><apiname> RProcess</apiname></xref>A handle to a process.</p></li>
       
    62 <li><p><xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname> CActive</apiname></xref> - The core class of the active object abstraction.</p></li>
       
    63 </ul></section>
       
    64 <section id="GUID-F8D41313-760D-417E-834C-09D41F4EDB06"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian build
       
    65 process</xref> describes how to build this example application. </p> <p>The
       
    66 example builds an executable called <filepath>Inverter.exe</filepath> and <filepath>Collector.exe</filepath> in
       
    67 the standard locations. </p> <p>To run the example, first build <filepath>Inverter.exe</filepath> and
       
    68 start <filepath>Collector.exe</filepath> from the file system or from your
       
    69 IDE. After launching the .exes (and depending on the emulator you are using)
       
    70 you may need to navigate away from the application launcher or shell screen
       
    71 to view the console. </p> <p>A message input console is used for user input
       
    72 and an output message console is used to display inverted words. The output
       
    73 message console that is displayed at startup. The user can switch between
       
    74 two consoles by <cmdname>Ctrl+Shift+Alt+t </cmdname> combination. </p> <p>The
       
    75 input message console is used to input words. A user presses enter to send
       
    76 the words to the Inverter and presses <cmdname>ESC</cmdname> to exit the application.
       
    77 When a user presses "Enter" the words go to the <codeph>InverterInQ</codeph>.
       
    78 The Inverter opens the <codeph>InverterInQ</codeph> at periodic intervals
       
    79 of 10 secs and inverts the words which it sends to the collector via <codeph>InverterOutQ</codeph>.
       
    80 The Collector opens the <codeph>InverterOutQ</codeph> and display the words
       
    81 in the output message console. </p> </section>
       
    82 </conbody></concept>