VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/obsolete/pralarm.h@ 51036

Last change on this file since 51036 was 11551, checked in by vboxsync, 17 years ago

API/xpcom: prefix any C symbols in VBoxXPCOM.so, to avoid namespace pollution. Enabled only on Linux at the moment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39** File: pralarm.h
40** Description: API to periodic alarms.
41**
42**
43** Alarms are defined to invoke some client specified function at
44** a time in the future. The notification may be a one time event
45** or repeated at a fixed interval. The interval at which the next
46** notification takes place may be modified by the client code only
47** during the respective notification.
48**
49** The notification is delivered on a thread that is part of the
50** alarm context (PRAlarm). The thread will inherit the priority
51** of the Alarm creator.
52**
53** Any number of periodic alarms (PRAlarmID) may be created within
54** the context of a single alarm (PRAlarm). The notifications will be
55** scheduled as close to the desired time as possible.
56**
57** Repeating periodic notifies are expected to run at a fixed rate.
58** That rate is expressed as some number of notifies per period where
59** the period is much larger than a PRIntervalTime (see prinrval.h).
60*/
61
62#if !defined(pralarm_h)
63#define pralarm_h
64
65#include "prtypes.h"
66#include "prinrval.h"
67
68#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
69#define PR_CreateAlarm VBoxNsprPR_CreateAlarm
70#define PR_DestroyAlarm VBoxNsprPR_DestroyAlarm
71#define PR_SetAlarm VBoxNsprPR_SetAlarm
72#define PR_ResetAlarm VBoxNsprPR_ResetAlarm
73#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
74
75PR_BEGIN_EXTERN_C
76
77/**********************************************************************/
78/************************* TYPES AND CONSTANTS ************************/
79/**********************************************************************/
80
81typedef struct PRAlarm PRAlarm;
82typedef struct PRAlarmID PRAlarmID;
83
84typedef PRBool (PR_CALLBACK *PRPeriodicAlarmFn)(
85 PRAlarmID *id, void *clientData, PRUint32 late);
86
87/**********************************************************************/
88/****************************** FUNCTIONS *****************************/
89/**********************************************************************/
90
91/***********************************************************************
92** FUNCTION: PR_CreateAlarm
93** DESCRIPTION:
94** Create an alarm context.
95** INPUTS: void
96** OUTPUTS: None
97** RETURN: PRAlarm*
98**
99** SIDE EFFECTS:
100** This creates an alarm context, which is an object used for subsequent
101** notification creations. It also creates a thread that will be used to
102** deliver the notifications that are expected to be defined. The client
103** is resposible for destroying the context when appropriate.
104** RESTRICTIONS:
105** None.
106** MEMORY: The object (PRAlarm) and a thread to support notifications.
107** ALGORITHM: N/A
108***********************************************************************/
109NSPR_API(PRAlarm*) PR_CreateAlarm(void);
110
111/***********************************************************************
112** FUNCTION: PR_DestroyAlarm
113** DESCRIPTION:
114** Destroys the context created by PR_CreateAlarm().
115** INPUTS: PRAlarm*
116** OUTPUTS: None
117** RETURN: PRStatus
118**
119** SIDE EFFECTS:
120** This destroys the context that was created by PR_CreateAlarm().
121** If there are any active alarms (PRAlarmID), they will be cancelled.
122** Once that is done, the thread that was used to deliver the alarms
123** will be joined.
124** RESTRICTIONS:
125** None.
126** MEMORY: N/A
127** ALGORITHM: N/A
128***********************************************************************/
129NSPR_API(PRStatus) PR_DestroyAlarm(PRAlarm *alarm);
130
131/***********************************************************************
132** FUNCTION: PR_SetAlarm
133** DESCRIPTION:
134** Creates a periodic notifier that is to be delivered to a specified
135** function at some fixed interval.
136** INPUTS: PRAlarm *alarm Parent alarm context
137** PRIntervalTime period Interval over which the notifies
138** are delivered.
139** PRUint32 rate The rate within the interval that
140** the notifies will be delivered.
141** PRPeriodicAlarmFn function Entry point where the notifies
142** will be delivered.
143** OUTPUTS: None
144** RETURN: PRAlarmID* Handle to the notifier just created
145** or NULL if the request failed.
146**
147** SIDE EFFECTS:
148** A periodic notifier is created. The notifications will be delivered
149** by the alarm's internal thread at a fixed interval whose rate is the
150** number of interrupts per interval specified. The first notification
151** will be delivered as soon as possible, and they will continue until
152** the notifier routine indicates that they should cease of the alarm
153** context is destroyed (PR_DestroyAlarm).
154** RESTRICTIONS:
155** None.
156** MEMORY: Memory for the notifier object.
157** ALGORITHM: The rate at which notifications are delivered are stated
158** to be "'rate' notifies per 'interval'". The exact time of
159** the notification is computed based on a epoch established
160** when the notifier was set. Each notification is delivered
161** not ealier than the epoch plus the fixed rate times the
162** notification sequence number. Such notifications have the
163** potential to be late by not more than 'interval'/'rate'.
164** The amount of lateness of one notification is taken into
165** account on the next in an attempt to avoid long term slew.
166***********************************************************************/
167NSPR_API(PRAlarmID*) PR_SetAlarm(
168 PRAlarm *alarm, PRIntervalTime period, PRUint32 rate,
169 PRPeriodicAlarmFn function, void *clientData);
170
171/***********************************************************************
172** FUNCTION: PR_ResetAlarm
173** DESCRIPTION:
174** Resets an existing alarm.
175** INPUTS: PRAlarmID *id Identify of the notifier.
176** PRIntervalTime period Interval over which the notifies
177** are delivered.
178** PRUint32 rate The rate within the interval that
179** the notifies will be delivered.
180** OUTPUTS: None
181** RETURN: PRStatus Indication of completion.
182**
183** SIDE EFFECTS:
184** An existing alarm may have its period and rate redefined. The
185** additional side effect is that the notifier's epoch is recomputed.
186** The first notification delivered by the newly refreshed alarm is
187** defined to be 'interval'/'rate' from the time of the reset.
188** RESTRICTIONS:
189** This function may only be called in the notifier for that alarm.
190** MEMORY: N/A.
191** ALGORITHM: See PR_SetAlarm().
192***********************************************************************/
193NSPR_API(PRStatus) PR_ResetAlarm(
194 PRAlarmID *id, PRIntervalTime period, PRUint32 rate);
195
196PR_END_EXTERN_C
197
198#endif /* !defined(pralarm_h) */
199
200/* prinrval.h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette