~ubuntu-branches/ubuntu/quantal/libbonobo/quantal-201207170711

« back to all changes in this revision

Viewing changes to doc/api/html/refcounting.html

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2009-09-26 01:14:29 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (3.1.5 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090926011429-0yhx3o44d8xve7kw
Tags: upstream-2.24.2
ImportĀ upstreamĀ versionĀ 2.24.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<head>
4
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>Reference Counting</title>
6
 
<meta name="generator" content="DocBook XSL Stylesheets V1.74.2">
 
6
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7
7
<link rel="home" href="index.html" title="Libbonobo Reference Manual">
8
8
<link rel="up" href="factories.html" title="Objects, Factories, Reference Counting">
9
9
<link rel="prev" href="libbonobo-bonobo-shlib-factory.html" title="bonobo-shlib-factory">
27
27
<th width="100%" align="center">Libbonobo Reference Manual</th>
28
28
<td><a accesskey="n" href="property-bags.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
29
29
</tr></table>
30
 
<div class="refentry" lang="en">
 
30
<div class="refentry" title="Reference Counting">
31
31
<a name="refcounting"></a><div class="titlepage"></div>
32
 
<div class="refsect1" lang="en">
33
 
<a name="id3007010"></a><h2>Reference Counting</h2>
 
32
<div class="refsect1" title="Reference Counting">
 
33
<a name="id2978713"></a><h2>Reference Counting</h2>
34
34
<p>
35
35
            Bonobo component reference counting, version 0.1
36
36
            by  Michael Meeks &lt;mmeeks@gnu.org&gt;
37
37
            and Mike Fleming &lt;mfleming@eazel.com&gt;
38
38
        </p>
39
 
<div class="refsect2" lang="en">
40
 
<a name="id3007022"></a><h3>Bonobo Objects</h3>
 
39
<div class="refsect2" title="Bonobo Objects">
 
40
<a name="id2978725"></a><h3>Bonobo Objects</h3>
41
41
<p>
42
42
                A bonobo object is a glib object that implements an
43
43
                CORBA interface, it also contains a pointer to the
68
68
                it can't be fiddled with elsewhere.</p>
69
69
</div>
70
70
<hr>
71
 
<div class="refsect2" lang="en">
72
 
<a name="id3007681"></a><h3>Ref counting</h3>
 
71
<div class="refsect2" title="Ref counting">
 
72
<a name="id2979385"></a><h3>Ref counting</h3>
73
73
<p> The only ref count to manipulate is that on the
74
74
                aggregate obejct, this is done via the
75
75
                <code class="function">bonobo_object_ref / unref</code> pair,
91
91
                is a very bad move indeed.</p>
92
92
</div>
93
93
<hr>
94
 
<div class="refsect2" lang="en">
95
 
<a name="id3007733"></a><h3>Reference leaks</h3>
 
94
<div class="refsect2" title="Reference leaks">
 
95
<a name="id2979436"></a><h3>Reference leaks</h3>
96
96
<p>
97
97
                Catching reference leaks is evily difficult. The first
98
98
                approach is to set environment variable
128
128
                worked out where the reference went astray.</p>
129
129
</div>
130
130
<hr>
131
 
<div class="refsect2" lang="en">
132
 
<a name="id3007808"></a><h3>Ref Counting Conventions</h3>
 
131
<div class="refsect2" title="Ref Counting Conventions">
 
132
<a name="id2979511"></a><h3>Ref Counting Conventions</h3>
133
133
<p>And now for the important stuff:</p>
134
 
<div class="refsect3" lang="en">
135
 
<a name="id3007816"></a><h4>Bonobo Ref Counting</h4>
 
134
<div class="refsect3" title="Bonobo Ref Counting">
 
135
<a name="id2979520"></a><h4>Bonobo Ref Counting</h4>
136
136
<p>The Bonobo ref count convention is as follows.
137
137
                    (Mild rewording; same meaning as before)</p>
138
 
<div class="orderedlist"><ol type="1">
139
 
<li><p> A function returning an object,
 
138
<div class="orderedlist"><ol class="orderedlist" type="1">
 
139
<li class="listitem"><p> A function returning an object,
140
140
                        either as the return value or by-reference,
141
141
                        must always add a reference before returning.
142
142
                        (Alternately: the callee must create a
143
143
                        reference to the returned object that the
144
144
                        caller owns)</p></li>
145
 
<li><p> A function that accepts a bonobo
 
145
<li class="listitem"><p> A function that accepts a bonobo
146
146
                        object as an in/out parameter must unreference
147
147
                        the originally passed object once if the
148
148
                        function wishes to change the value of the
149
149
                        in/out parameter.  (The function must ref()
150
150
                        new objects returned via this in/out in
151
151
                        accordance with [1]) </p></li>
152
 
<li><p> An object passed into a function
 
152
<li class="listitem"><p> An object passed into a function
153
153
                        needs only be ref()'d if the ifunction wishes
154
154
                        to retain a reference to the object beyond the
155
155
                        scope of the function call.</p></li>
161
161
                    casual code observers, and thus may cause hidden
162
162
                    side-effects.</p>
163
163
</div>
164
 
<div class="refsect3" lang="en">
165
 
<a name="id3007868"></a><h4>CORBA Ref-counting</h4>
 
164
<div class="refsect3" title="CORBA Ref-counting">
 
165
<a name="id2979572"></a><h4>CORBA Ref-counting</h4>
166
166
<p>Since the ORB also maintains reference counts
167
167
                    per interface handle, should you be returning a
168
168
                    reference to an object it is imperative to</p>
181
181
                    So to return an Unknown from a impl you can simply:</p>
182
182
<pre class="programlisting">
183
183
return bonobo_object_dup_ref (corba_object, ev);</pre>
184
 
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
 
184
<div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
185
185
<h3 class="title">Warning</h3>
186
186
<p>there is a caveat with this approach which is this:</p>
187
187
<p>If you construct a BonoboObject in an impl_
205
205
                        inserting it into a BonoboObjectClient.</p>
206
206
</div>
207
207
</div>
208
 
<div class="refsect3" lang="en">
209
 
<a name="id3007953"></a><h4>Ref counting and one-way methods</h4>
 
208
<div class="refsect3" title="Ref counting and one-way methods">
 
209
<a name="id2979656"></a><h4>Ref counting and one-way methods</h4>
210
210
<p>While the ORB has built in support for correct
211
211
                    referencing on 1 way methods, the Bonobo reference
212
212
                    count does not; hence if you wish to hand a bonobo