Symbian3/SDK/Source/GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     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 on the following link to download
       
    16 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 example describes the global message
       
    18 queue. The following sections provide more information. </p> <p><b> MessageQueueExample</b> </p> <p>The
       
    19 example comprises two processes: a Collector, which collects words from the
       
    20 user via the console, and an Inverter, which periodically reverses the order
       
    21 of the collected words. The Collector and the Inverter pass words to each
       
    22 other using two message queues: InverterInQ and InverterOutQ. The Collector
       
    23 is the main process which starts the Inverter process. The Collector process
       
    24 takes user input in form of different words and sends to the Inverter process
       
    25 via message queue. The Inverter process receives messages at a regular interval
       
    26 of 10 seconds, inverts the words in the message and sends it back to the Collector. </p> <p>The
       
    27 Collector creates an active object to collect words from the user and another
       
    28 active object to receive words from the Inverter. Each active object has its
       
    29 own console for display. More information about running the example is given
       
    30 in the build section of this document. </p> <p><b>Design</b> </p> <p>The following
       
    31 block diagram describes the example in more detail. </p> <fig id="GUID-27A0C389-EDDD-5E17-82EE-2727F21803AF">
       
    32 <image href="GUID-CD7F507C-CDD5-5612-BA1B-72641D28FA4A_d0e229882_href.png" placement="inline"/>
       
    33 </fig><p><filepath>CCollector.exe</filepath> is the Collector process. The
       
    34 user starts the Collector and creates an active scheduler and two global message
       
    35 queues. It also starts the Inverter process called <filepath>Inverter.exe</filepath>.
       
    36 The Collector creates one active object to collect words from the user and
       
    37 another active object to monitor its input queue (InverterOutQ). The active
       
    38 object to collect words is an object of class CCollector and the active object
       
    39 which monitors <codeph>InverterOutQ</codeph> is an object of class <xref href="GUID-A39BC295-2845-3018-B8B8-49418277E7EB.dita"><apiname>CMsgQActive</apiname></xref>.
       
    40 The two active objects have different consoles (one for user input and one
       
    41 for displaying the output message). </p><p> The user inputs words in the console.
       
    42 The set of words goes to the <codeph>InverterInQ</codeph> when the "<codeph>Enter</codeph>"
       
    43 key is pressed. If the "<codeph>ESC</codeph>" key is pressed, the system stops
       
    44 and sends the command to the Inverter process to stop.</p><p> The Inverter
       
    45 is another process which opens the global message queues. It creates an active
       
    46 scheduler and implements a periodic timer. The timer wakes every 10 seconds
       
    47 to receive the words from the <codeph>InverterInQ</codeph>. It also checks
       
    48 for a stop command, which closes the message queue and the two process. The
       
    49 Inverter inverts the received words and sends the result to <codeph>InverterOutQ</codeph>. </p><p>In
       
    50 the Collector process, the active object that monitors the <codeph>InveterOutQ</codeph> opens
       
    51 the message queue, receives the received words and displays  them in its console.
       
    52 It uses the <xref href="GUID-6E6B3CD0-FB61-336D-9357-2FFBE3F7A57A.dita"><apiname>NotifyDataAvailable()</apiname></xref> API to monitor the queue
       
    53 for the next set of data. </p><p>The Class diagram of the example is shown
       
    54 below </p><fig id="GUID-E93EF1D6-1B9D-4C76-80B0-1FF660B5C75A">
       
    55 <image href="GUID-3560E862-CB68-584F-B9B6-FCD9F0D202DC_d0e229930_href.png" placement="inline"/>
       
    56 </fig> </section>
       
    57 <section id="GUID-86B04D06-7046-49BD-AE1A-57D5E406F864"><title>Class summary</title><ul>
       
    58 <li><p> <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> - Periodic timer active object.</p></li>
       
    59 <li><p><xref href="GUID-5195B8D1-851E-3BEE-A72D-1841C0937300.dita"><apiname> RMsgQueue</apiname></xref> - A handle to a message queue.</p></li>
       
    60 <li><p><xref href="GUID-9DD1EA2B-DC59-315C-8E9C-CE6D9461B695.dita"><apiname> RProcess</apiname></xref>A handle to a process.</p></li>
       
    61 <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>
       
    62 </ul></section>
       
    63 <section id="GUID-F8D41313-760D-417E-834C-09D41F4EDB06"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian
       
    64 OS build process</xref> describes how to build this example application. </p> <p>The
       
    65 example builds an executable called <filepath>Inverter.exe</filepath> and <filepath>Collector.exe</filepath> in
       
    66 the standard locations. </p> <p>To run the example, first build <filepath>Inverter.exe</filepath> and
       
    67 start <filepath>Collector.exe</filepath> from the file system or from your
       
    68 IDE. After launching the .exes (and depending on the emulator you are using)
       
    69 you may need to navigate away from the application launcher or shell screen
       
    70 to view the console. </p> <p>A message input console is used for user input
       
    71 and an output message console is used to display inverted words. The output
       
    72 message console that is displayed at startup. The user can switch between
       
    73 two consoles by <cmdname>Ctrl+Shift+Alt+t </cmdname> combination. </p> <p>The
       
    74 input message console is used to input words. A user presses enter to send
       
    75 the words to the Inverter and presses <cmdname>ESC</cmdname> to exit the application.
       
    76 When a user presses "Enter" the words go to the <codeph>InverterInQ</codeph>.
       
    77 The Inverter opens the <codeph>InverterInQ</codeph> at periodic intervals
       
    78 of 10 secs and inverts the words which it sends to the collector via <codeph>InverterOutQ</codeph>.
       
    79 The Collector opens the <codeph>InverterOutQ</codeph> and display the words
       
    80 in the output message console. </p> </section>
       
    81 </conbody></concept>