|
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 task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-8F8E3814-7ED6-4218-BEEF-741AE0E9366F" xml:lang="en"><title>Changing |
|
13 the Priority</title><shortdesc>This section describes how an application (internal or third-party) |
|
14 can change its priority by using OOM Monitor APIs.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
15 <context id="GUID-FD9A15E9-6313-4BD3-A52A-7E3B71D39B37-GENID-1-10-1-11-1-1-9-1-5-1-6-1-4-1-3-1"><p>An application |
|
16 which is processing a task in the background can change its priority at runtime |
|
17 to protect itself from being closed by the OOM Monitor. For example:</p><ul> |
|
18 <li><p>Music Player playing music in the background</p></li> |
|
19 <li><p>Download Manager downloading a file in the background</p></li> |
|
20 </ul><p>If an application is processing a task for the user in the background, |
|
21 the application is said to be <codeph>Busy</codeph> and the OOM Monitor must |
|
22 not close a <codeph>Busy</codeph> application. An application can declare |
|
23 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. |
|
24 When the application finishes its background job and becomes idle, it should |
|
25 change its priority to <codeph>Normal</codeph>.</p></context> |
|
26 <steps id="GUID-01A482C7-3004-484D-9948-B0B892E913AF-GENID-1-10-1-11-1-1-9-1-5-1-6-1-4-1-3-2"> |
|
27 <step id="GUID-83631E4F-71D0-4FD2-8FD6-46689AAFA761-GENID-1-10-1-11-1-1-9-1-5-1-6-1-4-1-3-2-1"><cmd>Create an OOM Monitor |
|
28 session</cmd> |
|
29 <info><codeblock xml:space="preserve">ROomMonitorSession ioomMonitorSession; |
|
30 CleanUpClosePushL(ioomMonitorSession); |
|
31 User::LeaveIfError(ioomMonitorSession.Connect()); |
|
32 </codeblock></info> |
|
33 </step> |
|
34 <step id="GUID-3033BB28-ACC5-440C-9BDB-D1BC36CD001C-GENID-1-10-1-11-1-1-9-1-5-1-6-1-4-1-3-2-2"><cmd>Set the priority |
|
35 for the application to <codeph>Busy</codeph> before performing the background |
|
36 task</cmd> |
|
37 <info><codeblock xml:space="preserve">iOomMonitorSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy); |
|
38 DoCriticalBackgroundProcessingL(); |
|
39 </codeblock></info> |
|
40 </step> |
|
41 <step id="GUID-33674FB1-56E4-46C6-B267-107A42FA3B57"><cmd>Set the priority |
|
42 for the application to <codeph>Normal</codeph> after the task is completed.</cmd> |
|
43 <info><codeblock xml:space="preserve">iOomMonitorSession.SetOomPriority(ROomMonitorSession::EOomPriorityNormal); |
|
44 </codeblock></info> |
|
45 </step> |
|
46 <step id="GUID-5B3E8176-528F-45E7-B1CE-57ADCFAB5C6C-GENID-1-10-1-11-1-1-9-1-5-1-6-1-4-1-3-2-4"><cmd>Close the session.</cmd> |
|
47 <info><codeblock xml:space="preserve">iOomMonitorSession.Close(); |
|
48 </codeblock></info> |
|
49 </step> |
|
50 </steps> |
|
51 </taskbody><related-links> |
|
52 <link href="GUID-CE308C71-D8B2-43B3-97FD-B868285ED5FB.dita"><linktext>OOM Monitor |
|
53 Priority</linktext></link> |
|
54 <link href="GUID-39A8FBC9-5FD6-4F92-B71E-5C5438ECFD46.dita"><linktext>OOM Monitor |
|
55 Overview</linktext></link> |
|
56 <link href="GUID-88752800-83BD-4845-80A0-6B65D8D81924.dita"><linktext>OOM Monitor |
|
57 Reference</linktext></link> |
|
58 </related-links></task> |