Symbian3/SDK/Source/GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 8 ae94777fff8f
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     1
<?xml version="1.0" encoding="utf-8"?>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     2
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     3
<!-- This component and the accompanying materials are made available under the terms of the License 
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     4
"Eclipse Public License v1.0" which accompanies this distribution, 
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     5
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     6
<!-- Initial Contributors:
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     7
    Nokia Corporation - initial contribution.
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     8
Contributors: 
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     9
-->
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    10
<!DOCTYPE concept
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    11
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    12
<concept id="GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71" xml:lang="en"><title>condvar: Using Condition Variables</title><shortdesc>Examples that explains how to use condition variables. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    13
<p/>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    14
<ul>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    15
<li id="GUID-7CD8220E-2844-5FCB-A9B4-9B188F95C6EE"><p><xref href="GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71.dita#GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71/GUID-8209AA7E-0DFB-512D-9BEB-9063BA617BC5">condvarglobal</xref>  </p> </li>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    16
<li id="GUID-74DAFE22-039F-5647-B56E-6BB83B876DED"><p><xref href="GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71.dita#GUID-5C1E776D-5AEF-5326-BEA6-F2108F42CB71/GUID-8CF8C4E2-4D74-54C8-9601-97CC44B9C943">condvarlocal</xref>  </p> </li>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    17
</ul>
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    18
<section id="GUID-8209AA7E-0DFB-512D-9BEB-9063BA617BC5"><title>condvarglobal</title> <p>This example shows the use of the global condition variable IPC
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    19
mechanism. The scope of a global condition variable is inter-process.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    20
It can be shared by threads of any process in the system. </p> <p><b>Download</b> </p> <p>Click on the following link to download the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    21
example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-ddcb07c8-2646-4414-b33f-086f5758cbfe.zip" scope="external">condvarglobal .zip</xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-ddcb07c8-2646-4414-b33f-086f5758cbfe.html" scope="peer"> browse </xref> to view the example code</p><p><b>Class
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    22
summary</b></p><p> <xref href="GUID-D16EF740-78E6-3D08-AE2F-AFA5E812FF2B.dita"><apiname>RCondVar </apiname></xref> <xref href="GUID-C0FEA3A0-7DD3-3B87-A919-CB973BC05766.dita"><apiname>RMutex </apiname></xref> <xref href="GUID-326A2F4D-0E99-31C0-A35D-E8BF45913F07.dita"><apiname>RChunk </apiname></xref> <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> </p> <p><b>Description</b> </p> <p>This example uses an adder and subtractor
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    23
pattern to show the use of a global condition variable. Two processes,
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    24
the adder and the subtractor, modify a shared variable by adding and
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    25
subtracting random amounts. The condition variable ensures that the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    26
value remains within given limits, <codeph>KMaxValue</codeph> and <codeph>KMinValue</codeph>, by blocking one of the processes if the value
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    27
crosses a warning threshold. </p> <p>The adder program creates a global
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    28
shared memory chunk. It also creates a global mutex to control access
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    29
to the chunk and a global condition variable to signal that the value
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    30
in the chunk is '<codeph>ready for use</codeph>'. It then initialises
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    31
the value in the chunk to zero and periodically tries to add a random
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    32
value between 1 and 10 . If, having added a value, it finds that the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    33
value of the chunk is greater than <codeph>KUpperThreshold</codeph>, it waits for a signal from the condition variable before adding
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    34
another value. </p> <p>The subtractor program periodically tries to
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    35
subtract a random value between 1 and 10 from the global shared memory
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    36
chunk. If, having subtracted a value, it finds that the value of the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    37
chunk is less than <codeph>KLowerThreshold</codeph>, it waits for
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    38
a signal from the condition variable before subtracting another value. </p> <p><b>Design and implementation</b> </p> <fig id="GUID-1FAFB189-D2E4-5A05-8D8B-B3F7D28467FC">
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    39
<image href="GUID-857A523E-E660-5AFA-98B1-3A5440A8372F_d0e255233_href.jpg" placement="inline"/>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    40
</fig> <p><b>Build</b> </p> <p>The ConditionVariable example builds
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    41
the following binary files in the standard location (<filepath>\epoc32\release\winscw\
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    42
             &lt;build_variant&gt;</filepath>) for Carbide.c++. </p> <ul>
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    43
<li id="GUID-A699F4AF-3A5F-5C24-83CB-1762348AA1D2"><p> <b>adder.exe:</b> Demonstrates the use of the global condition variable. It creates
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    44
a global shared memory chunk and periodically adds random values to
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    45
the chunk. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    46
<li id="GUID-30A5BE77-8F99-5206-AD42-51E843D0D3C2"><p> <b>subtractor.exe:</b> Demonstrates the use of the global condition variable. It periodically
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    47
subtracts random values from the chunk created by <filepath>adder.exe</filepath>. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    48
</ul> <p><b>How to run the Example</b> </p> <p>To run the example,
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    49
perform the following steps: </p> <ol id="GUID-312A1E16-C92B-5C33-9D80-83080412E657">
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    50
<li id="GUID-E8E12006-8AAC-503D-B59A-F171092293F4"><p>Run <filepath>adder.exe</filepath>. </p> </li>
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    51
<li id="GUID-C9F80A69-218F-5467-9DDE-FC5849753E95"><p>Run eshell. </p> </li>
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    52
<li id="GUID-457E6D8F-A383-5CF6-BA6E-D98C8FAC20F4"><p>Run <filepath>subtract.exe</filepath> in your new eshell. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    53
<li id="GUID-122618AE-028B-5BF9-BB4B-4F95099EE839"><p>Switch between
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    54
eshells by pressing <b>CTRL+ALT+SHIFT+T</b>. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    55
<li id="GUID-24CCA548-D350-53A7-9919-270EA0C71EC1"><p>To finish, stop
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    56
each application by pressing any key. </p> </li>
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    57
</ol> </section>
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    58
<section id="GUID-8CF8C4E2-4D74-54C8-9601-97CC44B9C943"><title>condvarlocal</title> <p>This example shows the use of the local condition variable IPC
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    59
mechanism. The scope of a local condition variable is intra-process.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    60
It can be shared by threads of the process that creates the condition
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    61
variable. </p> <p><b>Download</b> </p> <p>Click on the following link
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    62
to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-527239ad-3eff-4d62-a7fe-b7e43658dd2f.zip" scope="external">condvarlocal .zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-527239ad-3eff-4d62-a7fe-b7e43658dd2f.html" scope="peer"> browse </xref> to view the example.</p> <p><b>Class
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    63
summary</b></p><p> <xref href="GUID-C0FEA3A0-7DD3-3B87-A919-CB973BC05766.dita"><apiname>RMutex </apiname></xref><xref href="GUID-B0E661BC-4058-3256-B9C3-5A4FD52F6DE5.dita"><apiname>RThread </apiname></xref>  <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic </apiname></xref> <xref href="GUID-D16EF740-78E6-3D08-AE2F-AFA5E812FF2B.dita"><apiname>RCondVar</apiname></xref></p> <p><b>Description</b> </p> <p>This example uses the producer and the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    64
consumer model to show the use of the local condition variable. </p> <p>The example creates two local threads: a producer and a consumer.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    65
The two threads share a buffer, which is an object of the <codeph>CQueue</codeph> class. The CQueue object creates a local condition
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    66
variable using the <codeph>RCondVar::CreateLocal()</codeph> function.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    67
It also defines the methods to insert and remove a token from the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    68
queue. The <codeph>CQueue::Insert()</codeph> function inserts a token
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    69
into the queue and signals the condition variable. The <codeph>CQueue::Remove()</codeph> function tries to remove a token from the queue. If the queue is
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    70
empty, it must wait for a signal from the condition variable. </p> <p>An object of the <codeph>CProducer</codeph> class creates and
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    71
calls the producer thread. The producer thread is called once every
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    72
two seconds using an object of the <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> class.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    73
This thread inserts a token into the queue when it is called. It calls
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    74
the <codeph>CQueue::Insert()</codeph> function on the shared <codeph>CQueue</codeph> object. </p> <p>An object of the <codeph>CConsumer</codeph> class creates and calls the consumer thread. The consumer thread
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    75
is called once a second using an object of the <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> class. This thread removes a token from the queue when it is called.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    76
It calls the <codeph>CQueue::Remove()</codeph> function on the shared <codeph>CQueue</codeph> object. </p> <p>For more information, refer to <xref href="http://support.entegrity.com/private/doclib/docs/osfhtm/develop/appdev/Appde179.htm" scope="external">Condition Variables</xref>. </p> <p> <note> Symbian
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    77
is not responsible for the content of external websites.</note>  </p> <p><b>Design and implementation</b> </p> <fig id="GUID-CA344322-0982-59C3-B93A-7A1F175728F3">
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    78
<image href="GUID-CAB30473-7829-5F2E-9F45-A2344DEDFC35_d0e255432_href.jpg" placement="inline"/>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    79
</fig> <p><b>Build</b> </p> <p>The Symbian build process describes
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    80
how to build this example. The ConditionVariable example builds the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    81
following binary files in the standard location (<filepath>\epoc32\release\winscw\
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    82
             &lt;build_variant&gt;</filepath>) for Carbide.c++. </p> <p> <filepath>condvarlocal.exe</filepath>: Demonstrates the use of the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    83
local condition variable. </p> <p><b>How to run the Example</b> </p> <p>To run the example, perform the following steps: </p> <ol id="GUID-D07D5782-6A32-5552-B42B-7D2672F1C94F">
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    84
<li id="GUID-CD0F5EAF-780F-5BC7-A216-2FE9CA3B284D"><p>Run <filepath>condvarlocal.exe</filepath>. The program calls the producer and the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    85
consumer threads periodically as shown in the description section.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    86
It also displays a menu. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    87
<li id="GUID-106E7D1D-4ECB-5FA2-A42C-CB1549F4811F"><p>Press <b>ā€˜dā€™</b> to display the contents of the queue. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    88
<li id="GUID-AA9ABD22-E280-5F21-A1A1-F47FFAAC58F2"><p>Press <b>ā€˜pā€™</b> to insert a token into the queue. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    89
<li id="GUID-96C5D556-0700-5632-80A1-E728C97A62C1"><p>Press any key
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 8
diff changeset
    90
to stop the program. </p> </li>
8
ae94777fff8f Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    91
</ol> </section>
7
51a74ef9ed63 Week 12 contribution of API Specs and fix SDK submission
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    92
</conbody></concept>