index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000004.html
dbus
dbus-resources.c
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-resources.c Resource tracking/limits
00003
*
00004
* Copyright (C) 2003  Red Hat Inc.
00005
*
00006
* Licensed under the Academic Free License version 2.1
00007
*
00008
* This program is free software; you can redistribute it and/or modify
00009
* it under the terms of the GNU General Public License as published by
00010
* the Free Software Foundation; either version 2 of the License, or
00011
* (at your option) any later version.
00012
*
00013
* This program is distributed in the hope that it will be useful,
00014
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00015
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016
* GNU General Public License for more details.
00017
*
00018
* You should have received a copy of the GNU General Public License
00019
* along with this program; if not, write to the Free Software
00020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021
*
00022
*/
00023
#include <dbus/dbus-resources.h>
00024
#include <dbus/dbus-internals.h>
00025
structDBusCounter.html
00052
struct
structDBusCounter.html
DBusCounter
00053 {
structDBusCounter.html#o0
00054
int
structDBusCounter.html#o0
refcount
;
structDBusCounter.html#o1
00056
long
structDBusCounter.html#o1
value
;
structDBusCounter.html#o2
00058
long
structDBusCounter.html#o2
notify_guard_value
;
structDBusCounter.html#o3
00059
DBusCounterNotifyFunction
structDBusCounter.html#o3
notify_function
;
structDBusCounter.html#o4
00060
void
*
structDBusCounter.html#o4
notify_data
;
00061 };
00062
/* end of resource limits internals docs */
00064
00076
structDBusCounter.html
DBusCounter
*
group__DBusResources.html#ga0
00077
group__DBusResources.html#ga0
_dbus_counter_new
(
void
)
00078 {
00079
structDBusCounter.html
DBusCounter
*counter;
00080
00081   counter =
group__DBusMemory.html#ga6
dbus_new
(
structDBusCounter.html
DBusCounter
, 1);
00082
if
(counter ==
group__DBusMacros.html#ga4
NULL
)
00083
return
group__DBusMacros.html#ga4
NULL
;
00084
00085   counter->
structDBusCounter.html#o0
refcount
= 1;
00086   counter->
structDBusCounter.html#o1
value
= 0;
00087
00088   counter->
structDBusCounter.html#o2
notify_guard_value
= 0;
00089   counter->
structDBusCounter.html#o3
notify_function
=
group__DBusMacros.html#ga4
NULL
;
00090   counter->
structDBusCounter.html#o4
notify_data
=
group__DBusMacros.html#ga4
NULL
;
00091
00092
return
counter;
00093 }
00094
00101
structDBusCounter.html
DBusCounter
*
group__DBusResources.html#ga1
00102
group__DBusResources.html#ga1
_dbus_counter_ref
(
structDBusCounter.html
DBusCounter
*counter)
00103 {
00104
group__DBusInternalsUtils.html#ga129
_dbus_assert
(counter->
structDBusCounter.html#o0
refcount
> 0);
00105
00106   counter->
structDBusCounter.html#o0
refcount
+= 1;
00107
00108
return
counter;
00109 }
00110
00117
void
group__DBusResources.html#ga2
00118
group__DBusResources.html#ga2
_dbus_counter_unref
(
structDBusCounter.html
DBusCounter
*counter)
00119 {
00120
group__DBusInternalsUtils.html#ga129
_dbus_assert
(counter->
structDBusCounter.html#o0
refcount
> 0);
00121
00122   counter->
structDBusCounter.html#o0
refcount
-= 1;
00123
00124
if
(counter->
structDBusCounter.html#o0
refcount
== 0)
00125     {
00126
00127
group__DBusMemory.html#ga3
dbus_free
(counter);
00128     }
00129 }
00130
00140
void
group__DBusResources.html#ga3
00141
group__DBusResources.html#ga3
_dbus_counter_adjust
(
structDBusCounter.html
DBusCounter
*counter,
00142
long
delta)
00143 {
00144
long
old = counter->
structDBusCounter.html#o1
value
;
00145
00146   counter->
structDBusCounter.html#o1
value
+= delta;
00147
00148
#if 0
00149
_dbus_verbose (
"Adjusting counter %ld by %ld = %ld\n"
,
00150                  old, delta, counter->
structDBusCounter.html#o1
value
);
00151
#endif
00152
00153
if
(counter->
structDBusCounter.html#o3
notify_function
!=
group__DBusMacros.html#ga4
NULL
&&
00154       ((old < counter->notify_guard_value &&
00155         counter->
structDBusCounter.html#o1
value
>= counter->
structDBusCounter.html#o2
notify_guard_value
) ||
00156        (old >= counter->
structDBusCounter.html#o2
notify_guard_value
&&
00157         counter->
structDBusCounter.html#o1
value
< counter->
structDBusCounter.html#o2
notify_guard_value
)))
00158     (* counter->
structDBusCounter.html#o3
notify_function
) (counter, counter->
structDBusCounter.html#o4
notify_data
);
00159 }
00160
00167
long
group__DBusResources.html#ga4
00168
group__DBusResources.html#ga4
_dbus_counter_get_value
(
structDBusCounter.html
DBusCounter
*counter)
00169 {
00170
return
counter->
structDBusCounter.html#o1
value
;
00171 }
00172
00183
void
group__DBusResources.html#ga5
00184
group__DBusResources.html#ga5
_dbus_counter_set_notify
(
structDBusCounter.html
DBusCounter
*counter,
00185
long
guard_value,
00186                           DBusCounterNotifyFunction  function,
00187
void
*user_data)
00188 {
00189   counter->
structDBusCounter.html#o2
notify_guard_value
= guard_value;
00190   counter->
structDBusCounter.html#o3
notify_function
= function;
00191   counter->
structDBusCounter.html#o4
notify_data
= user_data;
00192 }
00193
/* end of resource limits exported API */
Generated on Tue Sep 13 00:15:26 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
