Symbian3/SDK/Source/GUID-8F8E3814-7ED6-4218-BEEF-741AE0E9366F.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-8F8E3814-7ED6-4218-BEEF-741AE0E9366F" xml:lang="en"><title>Changing
the Priority</title><shortdesc>This section describes how an application (internal or third-party)
can change its priority by using OOM Monitor APIs.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context id="GUID-FD9A15E9-6313-4BD3-A52A-7E3B71D39B37-GENID-1-10-1-10-1-1-8-1-5-1-6-1-4-1-3-1"><p>An application
which is processing a task in the background can change its priority at runtime
to protect itself from being closed by the OOM Monitor. For example:</p><ul>
<li><p>Music Player playing music in the background</p></li>
<li><p>Download Manager downloading a file in the background</p></li>
</ul><p>If an application is processing a task for the user in the background,
the application is said to be <codeph>Busy</codeph> and the OOM Monitor must
not close a <codeph>Busy</codeph> application. An application can declare
itself to be <codeph>Busy</codeph> using <xref href="GUID-02D1911A-D2E5-3D28-9B05-75DA0A75DE73.dita#GUID-02D1911A-D2E5-3D28-9B05-75DA0A75DE73/GUID-420ECF8B-970A-381A-9035-DC1FCE8B566C"><apiname>ROomMonitorSession::SetOomPriority(EOomPriorityBusy)</apiname></xref> method.
When the application finishes its background job and becomes idle, it should
change its priority to <codeph>Normal</codeph>.</p></context>
<steps id="GUID-01A482C7-3004-484D-9948-B0B892E913AF-GENID-1-10-1-10-1-1-8-1-5-1-6-1-4-1-3-2">
<step id="GUID-83631E4F-71D0-4FD2-8FD6-46689AAFA761-GENID-1-10-1-10-1-1-8-1-5-1-6-1-4-1-3-2-1"><cmd>Create an OOM Monitor
session</cmd>
<info><codeblock xml:space="preserve">ROomMonitorSession ioomMonitorSession;
CleanUpClosePushL(ioomMonitorSession);
User::LeaveIfError(ioomMonitorSession.Connect());
</codeblock></info>
</step>
<step id="GUID-3033BB28-ACC5-440C-9BDB-D1BC36CD001C-GENID-1-10-1-10-1-1-8-1-5-1-6-1-4-1-3-2-2"><cmd>Set the priority
for the application to <codeph>Busy</codeph> before performing the background
task</cmd>
<info><codeblock xml:space="preserve">iOomMonitorSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy);
DoCriticalBackgroundProcessingL();
</codeblock></info>
</step>
<step id="GUID-33674FB1-56E4-46C6-B267-107A42FA3B57"><cmd>Set the priority
for the application to <codeph>Normal</codeph> after the task is completed.</cmd>
<info><codeblock xml:space="preserve">iOomMonitorSession.SetOomPriority(ROomMonitorSession::EOomPriorityNormal);
</codeblock></info>
</step>
<step id="GUID-5B3E8176-528F-45E7-B1CE-57ADCFAB5C6C-GENID-1-10-1-10-1-1-8-1-5-1-6-1-4-1-3-2-4"><cmd>Close the session.</cmd>
<info><codeblock xml:space="preserve">iOomMonitorSession.Close();
</codeblock></info>
</step>
</steps>
</taskbody><related-links>
<link href="GUID-CE308C71-D8B2-43B3-97FD-B868285ED5FB.dita"><linktext>OOM Monitor
Priority</linktext></link>
<link href="GUID-39A8FBC9-5FD6-4F92-B71E-5C5438ECFD46.dita"><linktext>OOM Monitor
Overview</linktext></link>
<link href="GUID-88752800-83BD-4845-80A0-6B65D8D81924.dita"><linktext>OOM Monitor
Reference</linktext></link>
</related-links></task>