<html> <head> <title>Global Functions in Namespace in Sourcefile unload.h</title> <link rel="stylesheet" type="text/css" href="../cpp.css"> </head> <body> <div id="adc-cppref"> <a name="_top_"> </a><table class="navimain" border="0" cellpadding="1" cellspacing="0"> <tr align="center" valign="top"> <td class="navimain"> <a href="../index.html">Overview</a> </td> <td class="navimain"> <a href="index.html">Namespace</a> </td> <td class="navimainnone"> Class </td> <td class="navimain"> <a href="../index-files/index-1.html">Index</a> </td> <td class="navimain"> <a href="../help.html">Help</a> </td> </tr> </table> <table class="navisub" cellpadding="0" cellspacing="3"></table> <hr> <div class="title"><h2>Global Functions in Global Namespace C++<br> in Sourcefile unload.h</h2> </div><hr> <dl class="member"> <dt class="member"><a name="rtl_addUnloadingListener-1421"> </a>rtl_addUnloadingListener</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> <a href="t-sal_Int32.html">sal_Int32</a> <strong>rtl_addUnloadingListener</strong>(</dt> <dd><table class="param-table"> <tr> <td>rtl_unloadingListenerFunc </td> <td> callback,</td> </tr> <tr> <td>void *</td> <td>_this );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Description</dt> <dd>The function registered an unloading listener. The callback argument is a function which is called when the unloading procedure has been initiated by a call to <code>rtl_unloadUnusedLibraries</code>. The second argument is used to distinguish between different listener instances and may be <code>NULL</code>. It will be passed as argument when the callback function is being called. The return value identifies the registered listener and will be used for removing the listener later on. If the same listener is added more then once then every registration is treated as if made for a different listener. That is, a different cookie is returned and the callback function will be called as many times as it has been registered. </dd> <dt>Parameters</dt> <dd><table border="0" width="100%" cellpadding="3" cellspacing="0" class="expl-table"> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">callback</td> <td><pre>- a function that is called to notify listeners. </pre></td> </tr> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">this</td> <td><pre>- a value to distinguish different listener instances </pre></td> </tr> </table> </dd> <dt>Return</dt> <dd>identifier which is used in rtl_removeUnloadingListener </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_moduleCount_acquire-1430"> </a>rtl_moduleCount_acquire</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> void <strong>rtl_moduleCount_acquire</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-rtl_ModuleCount.html">rtl_ModuleCount</a> * </td> <td> that );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Summary</dt> <dd>Default implementation for <code>rtl_ModuleCount.acquire</code>. Use this function along with <code>rtl_StandardModuleCount</code>. </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_moduleCount_canUnload-1432"> </a>rtl_moduleCount_canUnload</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> <a href="t-sal_Bool.html">sal_Bool</a> <strong>rtl_moduleCount_canUnload</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-rtl_StandardModuleCount.html">rtl_StandardModuleCount</a> * </td> <td> that,</td> </tr> <tr> <td><a href="t-TimeValue.html">TimeValue</a> *</td> <td>libUnused );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Summary</dt> <dd>Default implementation for <code>component_canUnload</code>. Use this function along with <code>rtl_StandardModuleCount</code>. </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_moduleCount_release-1431"> </a>rtl_moduleCount_release</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> void <strong>rtl_moduleCount_release</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-rtl_ModuleCount.html">rtl_ModuleCount</a> * </td> <td> that );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Description</dt> <dd>Default implementation for <code>rtl_ModuleCount.release</code>. Use this function along with <code>rtl_StandardModuleCount</code>. </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_registerModuleForUnloading-1418"> </a>rtl_registerModuleForUnloading</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> <a href="t-sal_Bool.html">sal_Bool</a> <strong>rtl_registerModuleForUnloading</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-oslModule.html">oslModule</a> </td> <td> module );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Summary</dt> <dd>By registering a module, one declares that a module supports the unloading mechanism. One registers a module by calling this function.<p> </dd> <dt>Description</dt> <dd>A module can only be unloaded from memory when it has been registered as many times as it has been loaded. The reason is that a library can be "loaded" several times by <code>osl_loadModule</code> within the same process. The function will then return the same module handle because the library will effectively only be loaded once. To remove the library from memory it is necessary to call <code>osl_unloadModule</code> as often as <code> osl_loadModule</code> was called. The function <code>rtl_unloadUnusedModules</code> calls <code>osl_unloadModule</code> for a module as many times as it was registered. If, for example, a module has been registered one time less then <code>osl_loadModule</code> has been called and the module can be unloaded then it needs a call to <code>rtl_unloadUnusedModules</code> and an explicit call to <code>osl_unloadModule</code> to remove the module from memory. <p> A module must be registered every time it has been loaded otherwise the unloading mechanism is not effective.<p> Before a module is registered, one has to make sure that the module is in a state that prevents it from being unloaded. In other words, <code>component_canUnload</code> must return <code>sal_False</code>. Assuming that <code>component_canUnload</code> returns <code>sal_True</code> and it is registered regardless, then a call to <code>rtl_unloadUnusedModules</code> causes the module to be unloaded. This unloading can be set off by a different thread and the thread which registered the module is "unaware" of this. Then when the first thread tries to obtain a factory or calls another function in the module, the application will crash, because the module has been unloaded before. Therefore one has to ensure that the module cannot be unloaded before it is registered. This is simply done by obtaining a factory from the module. As long as a factory or some other object, which has been created by the factory, is alive, the <code>component_canUnload</code> function will return <code>sal_False</code>.<p> Loading and registering have to be in this order:<br> <ul> <li>load a library (<code>osl_loadModule</code>)</li> <li>get the <code>component_getFactory</code> function and get a factory</li> <li>register the module (rtl_registerModuleForUnloading</li> </ul> Usually the service manager is used to obtain an instance of a service. The service manager registers all modules which support the unloading mechanism. When the service manager is used to get service instances than one does not have to bother about registering. </dd> <dt>Parameters</dt> <dd><table border="0" width="100%" cellpadding="3" cellspacing="0" class="expl-table"> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">module</td> <td><pre>a module handle as is obtained by osl_loadModule </pre></td> </tr> </table> </dd> <dt>Return</dt> <dd>sal_True - the module could be registered for unloading, sal_False otherwise </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_removeUnloadingListener-1422"> </a>rtl_removeUnloadingListener</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> void <strong>rtl_removeUnloadingListener</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-sal_Int32.html">sal_Int32</a> </td> <td> cookie );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Description</dt> <dd>Listeners (the callback functions) must be unregistered before the listener code becomes invalid. That is, if a module contains listener code, namely callback functions of type <code>rtl_unloadingListenerFunc</code>, then those functions must not be registered when <code>component_canUnload</code> returns <code>sal_True</code>. </dd> <dt>Parameters</dt> <dd><table border="0" width="100%" cellpadding="3" cellspacing="0" class="expl-table"> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">cookie</td> <td><pre>is an identifier as returned by <code>rtl_addUnloadingListener</code> function. </pre></td> </tr> </table> </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_unloadUnusedModules-1420"> </a>rtl_unloadUnusedModules</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> void <strong>rtl_unloadUnusedModules</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-TimeValue.html">TimeValue</a> * </td> <td> libUnused );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Description</dt> <dd>This function sets off the unloading mechanism. At first it notifies the unloading listeners in order to give them a chance to do cleanup and get their threads in a safe state. Then all registered modules are asked if they can be unloaded. That is, the function calls component_canUnload on every registered module. If <code>sal_True</code> is returned then <code>osl_unloadModule</code> is called for the belonging module as often as it is registered. <p> A call to <code>osl_unloadModule</code> does not guarantee that the module is unloaded even if its <code>component_canUnload</code> function returns <code>sal_True</code>. <p> The optional in-parameter <code>libUnused</code> specifies a period of time which a library must be unused in order to qualify for being unloaded. By using this argument one can counter the multithreading problem as described further above. It is in the responsibility of the user of this function to provide a timespan big enough to ensure that all threads are out of modules (see <code>component_canUnload</code>). <p> The service managers which have been created by functions such as <code>createRegistryServiceFactory</code> (declared in cppuhelper/servicefactory.hxx) are registered listeners and release the references to factories on notification. </dd> <dt>Parameters</dt> <dd><table border="0" width="100%" cellpadding="3" cellspacing="0" class="expl-table"> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">libUnused</td> <td><pre>span of time that a module must be unused to be unloaded. the argument is optional. </pre></td> </tr> </table> </dd> </dl> </dd> </dl> <hr> <dl class="member"> <dt class="member"><a name="rtl_unregisterModuleForUnloading-1419"> </a>rtl_unregisterModuleForUnloading</dt> <dd class="member"><dl> <dt class="simple">extern "C"<br> void <strong>rtl_unregisterModuleForUnloading</strong>(</dt> <dd><table class="param-table"> <tr> <td><a href="t-oslModule.html">oslModule</a> </td> <td> module );</td> </tr> </table> </dd> </dl> <br> </dd> <dd class="member"><table class="flag-table" border="1" cellspacing="0"> <tr> <td width="12%" class="flagname">virtual</td> <td width="12%" class="flagname">abstract</td> <td width="12%" class="flagname">const</td> <td width="12%" class="flagname">volatile</td> <td width="12%" class="flagname">template</td> <td width="12%" class="flagname">static</td> <td width="12%" class="flagname">inline</td> <td width="12%" class="flagname">C-linkage</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagyes">YES</td> </tr> </table> <br> </dd> <dd class="member"><dl> <dt>Description</dt> <dd>The function revokes the registration of a module. By calling the function for a previously registered module one prevents the module from being unloaded by this unloading mechanism. However, in order to completely unregister the module it is necessary to call the function as often as the module has been registered. <p> <code>rtl_unloadUnusedModules</code> unregisters the modules which it unloads. Therefore there is no need to call this function unless one means to prevent the unloading of a module. </dd> <dt>Parameters</dt> <dd><table border="0" width="100%" cellpadding="3" cellspacing="0" class="expl-table"> <tr> <td width="15%" style="vertical-align:top; font-weight:bold">module</td> <td><pre>a module handle as is obtained by osl_loadModule </pre></td> </tr> </table> </dd> </dl> </dd> </dl> <hr> <a href="#_top_" class="objchapter">Top of Page</a><hr size="3"><p class="copyright" align="center">Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.</p> </div> <!-- id="adc-cppref" --> </body> </html>