Difference between revisions of "Documentation/DevGuide/ProUNO/acquire() and release()"
m |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/ProUNO/The XComponent Interface | |NextPage=Documentation/DevGuide/ProUNO/The XComponent Interface | ||
}} | }} | ||
− | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}} | |
{{DISPLAYTITLE:acquire() and release()}} | {{DISPLAYTITLE:acquire() and release()}} | ||
Every UNO interface is derived from <idl>com.sun.star.uno.XInterface</idl>: | Every UNO interface is derived from <idl>com.sun.star.uno.XInterface</idl>: | ||
− | < | + | <syntaxhighlight lang="idl"> |
// module com::sun::star::uno | // module com::sun::star::uno | ||
interface XInterface | interface XInterface | ||
Line 18: | Line 18: | ||
[oneway] void release(); | [oneway] void release(); | ||
}; | }; | ||
− | </ | + | </syntaxhighlight> |
UNO objects must maintain an internal reference counter. Calling <code>acquire()</code> on a UNO interface increases the reference count by one. Calling <code>release()</code> on UNO interfaces decreases the reference count by one. If the reference count drops to zero, the UNO object may be destroyed. Destruction of an object is sometimes called ''death'' of an object or that the object dies. The reference count of an object must always be non-negative. | UNO objects must maintain an internal reference counter. Calling <code>acquire()</code> on a UNO interface increases the reference count by one. Calling <code>release()</code> on UNO interfaces decreases the reference count by one. If the reference count drops to zero, the UNO object may be destroyed. Destruction of an object is sometimes called ''death'' of an object or that the object dies. The reference count of an object must always be non-negative. | ||
Line 27: | Line 27: | ||
The invocation of a method is allowed first when <code>acquire ()</code> has been called before. For every call to <code>acquire()</code>, there must be a corresponding release call, otherwise the object leaks. | The invocation of a method is allowed first when <code>acquire ()</code> has been called before. For every call to <code>acquire()</code>, there must be a corresponding release call, otherwise the object leaks. | ||
− | {{ | + | {{Note|The UNO Java binding encapsulates <tt>acquire()</tt> and <tt>release()</tt> in the <tt>UnoRuntime.queryInterface()</tt> call. The same applies to the <tt>Reference<></tt> template in C++. As long as the interface references are obtained through these mechanisms, <tt>acquire()</tt> and <tt>release()</tt> do not have to be called in your programs.}} |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Professional UNO]] | [[Category:Documentation/Developer's Guide/Professional UNO]] |
Latest revision as of 12:21, 23 December 2020
Every UNO interface is derived from com.sun.star.uno.XInterface:
// module com::sun::star::uno interface XInterface { any queryInterface( [in] type aType ); [oneway] void acquire(); [oneway] void release(); };
UNO objects must maintain an internal reference counter. Calling acquire()
on a UNO interface increases the reference count by one. Calling release()
on UNO interfaces decreases the reference count by one. If the reference count drops to zero, the UNO object may be destroyed. Destruction of an object is sometimes called death of an object or that the object dies. The reference count of an object must always be non-negative.
Once acquire()
is called on the UNO object, there is a reference or a hard reference to the object, as opposed to a weak reference. Calling release()
on the object is often called releasing or clearing the reference.
The UNO object does not export the state of the reference count, that is, acquire()
and release()
do not have return values. Generally, the UNO object should not make any assumptions on the concrete value of the reference count, except for the transition from one to zero.
The invocation of a method is allowed first when acquire ()
has been called before. For every call to acquire()
, there must be a corresponding release call, otherwise the object leaks.
Content on this page is licensed under the Public Documentation License (PDL). |