Symbian3/SDK/Source/GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C.dita
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
equal deleted inserted replaced
7:51a74ef9ed63 8:ae94777fff8f
     7     Nokia Corporation - initial contribution.
     7     Nokia Corporation - initial contribution.
     8 Contributors: 
     8 Contributors: 
     9 -->
     9 -->
    10 <!DOCTYPE concept
    10 <!DOCTYPE concept
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    12 <concept id="GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C" xml:lang="en"><title>MessageQueue
    12 <concept id="GUID-C21BB0E4-7AF7-58E5-AAD6-8CE67399460C" xml:lang="en"><title>MessageQueue Example</title><shortdesc>This example application shows the use of message queue
    13 Example</title><shortdesc>This example application shows the use of message queue in interprocess
    13 in interprocess communication using the RMsgQueue class.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 communication using the RMsgQueue class.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 <section id="GUID-ED679CA7-FF4C-4E69-8663-5DA46A3D94F4"><title>Download</title> <p>Click 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>
    15 <section id="GUID-ED679CA7-FF4C-4E69-8663-5DA46A3D94F4"><title>Download</title> <p>Click
    15 <section id="GUID-39D2064D-AD24-4785-956F-18A0CAD57B81"><title>Description</title> <p>The example describes the global message queue. The following
    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>
    16 sections provide more information. </p> <p><b> MessageQueueExample</b> </p> <p>The example comprises two processes: a Collector, which
    17 <section id="GUID-39D2064D-AD24-4785-956F-18A0CAD57B81"><title>Description</title> <p>The
    17 collects words from the user via the console, and an Inverter, which
    18 example describes the global message queue. The following sections provide
    18 periodically reverses the order of the collected words. The Collector
    19 more information. </p> <p><b> MessageQueueExample</b> </p> <p>The example
    19 and the Inverter pass words to each other using two message queues:
    20 comprises two processes: a Collector, which collects words from the user via
    20 InverterInQ and InverterOutQ. The Collector is the main process which
    21 the console, and an Inverter, which periodically reverses the order of the
    21 starts the Inverter process. The Collector process takes user input
    22 collected words. The Collector and the Inverter pass words to each other using
    22 in form of different words and sends to the Inverter process via message
    23 two message queues: InverterInQ and InverterOutQ. The Collector is the main
    23 queue. The Inverter process receives messages at a regular interval
    24 process which starts the Inverter process. The Collector process takes user
    24 of 10 seconds, inverts the words in the message and sends it back
    25 input in form of different words and sends to the Inverter process via message
    25 to the Collector. </p> <p>The Collector creates an active object to
    26 queue. The Inverter process receives messages at a regular interval of 10
    26 collect words from the user and another active object to receive words
    27 seconds, inverts the words in the message and sends it back to the Collector. </p> <p>The
    27 from the Inverter. Each active object has its own console for display.
    28 Collector creates an active object to collect words from the user and another
    28 More information about running the example is given in the build section
    29 active object to receive words from the Inverter. Each active object has its
    29 of this document. </p> <p><b>Design</b> </p> <p>The following block
    30 own console for display. More information about running the example is given
    30 diagram describes the example in more detail. </p> <fig id="GUID-27A0C389-EDDD-5E17-82EE-2727F21803AF">
    31 in the build section of this document. </p> <p><b>Design</b> </p> <p>The following
    31 <image href="GUID-CD7F507C-CDD5-5612-BA1B-72641D28FA4A_d0e254198_href.png" placement="inline"/>
    32 block diagram describes the example in more detail. </p> <fig id="GUID-27A0C389-EDDD-5E17-82EE-2727F21803AF">
    32 </fig><p><filepath>CCollector.exe</filepath> is the Collector process.
    33 <image href="GUID-CD7F507C-CDD5-5612-BA1B-72641D28FA4A_d0e257906_href.png" placement="inline"/>
    33 The user starts the Collector and creates an active scheduler and
    34 </fig><p><filepath>CCollector.exe</filepath> is the Collector process. The
    34 two global message queues. It also starts the Inverter process called <filepath>Inverter.exe</filepath>. The Collector creates one active object
    35 user starts the Collector and creates an active scheduler and two global message
    35 to collect words from the user and another active object to monitor
    36 queues. It also starts the Inverter process called <filepath>Inverter.exe</filepath>.
    36 its input queue (InverterOutQ). The active object to collect words
    37 The Collector creates one active object to collect words from the user and
    37 is an object of class CCollector and the active object which monitors <codeph>InverterOutQ</codeph> is an object of class <xref href="GUID-A39BC295-2845-3018-B8B8-49418277E7EB.dita"><apiname>CMsgQActive</apiname></xref>. The two active objects have different consoles (one for user input
    38 another active object to monitor its input queue (InverterOutQ). The active
    38 and one for displaying the output message). </p><p> The user inputs
    39 object to collect words is an object of class CCollector and the active object
    39 words in the console. The set of words goes to the <codeph>InverterInQ</codeph> when the "<codeph>Enter</codeph>" key is pressed. If the "<codeph>ESC</codeph>" key is pressed, the system stops and sends the command
    40 which monitors <codeph>InverterOutQ</codeph> is an object of class <xref href="GUID-A39BC295-2845-3018-B8B8-49418277E7EB.dita"><apiname>CMsgQActive</apiname></xref>.
    40 to the Inverter process to stop.</p><p> The Inverter is another process
    41 The two active objects have different consoles (one for user input and one
    41 which opens the global message queues. It creates an active scheduler
    42 for displaying the output message). </p><p> The user inputs words in the console.
    42 and implements a periodic timer. The timer wakes every 10 seconds
    43 The set of words goes to the <codeph>InverterInQ</codeph> when the "<codeph>Enter</codeph>"
    43 to receive the words from the <codeph>InverterInQ</codeph>. It also
    44 key is pressed. If the "<codeph>ESC</codeph>" key is pressed, the system stops
    44 checks for a stop command, which closes the message queue and the
    45 and sends the command to the Inverter process to stop.</p><p> The Inverter
    45 two process. The Inverter inverts the received words and sends the
    46 is another process which opens the global message queues. It creates an active
    46 result to <codeph>InverterOutQ</codeph>. </p><p>In the Collector process,
    47 scheduler and implements a periodic timer. The timer wakes every 10 seconds
    47 the active object that monitors the <codeph>InveterOutQ</codeph> opens
    48 to receive the words from the <codeph>InverterInQ</codeph>. It also checks
    48 the message queue, receives the received words and displays  them
    49 for a stop command, which closes the message queue and the two process. The
    49 in its console. It uses the <xref href="GUID-22E24B08-175B-3446-9D48-9AC4B1663E35.dita"><apiname>NotifyDataAvailable(TRequestStatus&amp;)</apiname></xref> API to monitor the queue for the next set of data. </p><p>The Class diagram of the example is shown below </p><fig id="GUID-E93EF1D6-1B9D-4C76-80B0-1FF660B5C75A">
    50 Inverter inverts the received words and sends the result to <codeph>InverterOutQ</codeph>. </p><p>In
    50 <image href="GUID-3560E862-CB68-584F-B9B6-FCD9F0D202DC_d0e254247_href.png" placement="inline"/>
    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>
    51 </fig> </section>
    58 <section id="GUID-86B04D06-7046-49BD-AE1A-57D5E406F864"><title>Class summary</title><ul>
    52 <section id="GUID-86B04D06-7046-49BD-AE1A-57D5E406F864"><title>Class
       
    53 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>
    54 <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>
    55 <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>
    56 <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>
    57 <li><p><xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname> CActive</apiname></xref> - The core class of the active
       
    58 object abstraction.</p></li>
    63 </ul></section>
    59 </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
    60 <section id="GUID-F8D41313-760D-417E-834C-09D41F4EDB06"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian
    65 process</xref> describes how to build this example application. </p> <p>The
    61 build process</xref> describes how to build this example application. </p> <p>The example builds an executable called <filepath>Inverter.exe</filepath> and <filepath>Collector.exe</filepath> in the standard locations. </p> <p>To run the example, first build <filepath>Inverter.exe</filepath> and start <filepath>Collector.exe</filepath> from the file system
    66 example builds an executable called <filepath>Inverter.exe</filepath> and <filepath>Collector.exe</filepath> in
    62 or from your IDE. After launching the .exes (and depending on the
    67 the standard locations. </p> <p>To run the example, first build <filepath>Inverter.exe</filepath> and
    63 emulator you are using) you may need to navigate away from the application
    68 start <filepath>Collector.exe</filepath> from the file system or from your
    64 launcher or shell screen to view the console. </p> <p>A message input
    69 IDE. After launching the .exes (and depending on the emulator you are using)
    65 console is used for user input and an output message console is used
    70 you may need to navigate away from the application launcher or shell screen
    66 to display inverted words. The output message console that is displayed
    71 to view the console. </p> <p>A message input console is used for user input
    67 at startup. The user can switch between two consoles by <cmdname>Ctrl+Shift+Alt+t </cmdname> combination. </p> <p>The input message console is used to input
    72 and an output message console is used to display inverted words. The output
    68 words. A user presses enter to send the words to the Inverter and
    73 message console that is displayed at startup. The user can switch between
    69 presses <cmdname>ESC</cmdname> to exit the application. When a user
    74 two consoles by <cmdname>Ctrl+Shift+Alt+t </cmdname> combination. </p> <p>The
    70 presses "Enter" the words go to the <codeph>InverterInQ</codeph>.
    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
    71 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>.
    72 of 10 secs and inverts the words which it sends to the collector via <codeph>InverterOutQ</codeph>. The Collector opens the <codeph>InverterOutQ</codeph> and display the words in the output message console. </p> </section>
    80 The Collector opens the <codeph>InverterOutQ</codeph> and display the words
       
    81 in the output message console. </p> </section>
       
    82 </conbody></concept>
    73 </conbody></concept>