NPN_PluginThreadAsyncCall

  • Revision slug: NPN_PluginThreadAsyncCall
  • Revision title: NPN_PluginThreadAsyncCall
  • Revision id: 90135
  • Created:
  • Creator: FocusStealer
  • Is current revision? No
  • Comment Trivial fix of parameter name; 1 words added, 1 words removed

Revision Content

{{ Np-browser-api() }} {{ Gecko_minversion_header("1") }}

Summary

Thread safe way to request that the browser calls a plug-in function on the browser or plugin thread (the thread on which the plug-in was initiated).

Syntax

#include <npapi.h>
 
void
NPN_PluginThreadAsyncCall(NPP plugin,
                          void (*func)(void *),
                          void *userData);

Parameters

The function has the following parameters:

plugin
Pointer to the current plug-in instance.
func
Pointer to the function to call on the correct thread.
userData
Pointer to the data to pass to the function func once called.

Returns

  • Nothing.

Description

Causes asynchronous execution of the specified function pointer on the "plug-in thread", passing in the specified user data pointer when it is called. The "plug-in thread" is the thread hosting the plug-in, which may be either the browser's main thread or the plug-in process if the plug-in is being executed out-of-process.

It is the application's responsibility to perform any synchronization between the thread calling NPN_PluginThreadAsyncCall() and the thread on which the call is eventually executed. In particular, the user must ensure that the function pointer remains callable and the user data is not deallocated until the browser executes the call.

There are inherent race conditions between calling this function and termination of the plug-in instance. The browser might not execute calls successfully registered with this API call during plug-in termination. Plug-ins should perform appropriate synchronization with the code in their NPP_Destroy() routine to ensure correct execution and avoid memory leaks.

Calling NPN_PluginThreadAsyncCall() on the "browser main thread" or the "plug-in thread" is legal; the call to NPN_PluginThreadAsyncCall() returns immediately. After control returns to the browser, it is free to call the function with its argument from this thread.

See Also

Revision Source

<p>{{ Np-browser-api() }} {{ Gecko_minversion_header("1") }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Thread safe way to request that the browser calls a plug-in function on the browser or plugin thread (the thread on which the plug-in was initiated).</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre>#include &lt;npapi.h&gt;
 
void
NPN_PluginThreadAsyncCall(NPP plugin,
                          void (*func)(void *),
                          void *userData);
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<p>The function has the following parameters:</p>
<dl> <dt><code>plugin<br> </code></dt> <dd>Pointer to the current plug-in instance.</dd>
</dl>
<dl> <dt><code>func</code></dt> <dd>Pointer to the function to call on the correct thread.</dd>
</dl>
<dl> <dt><code>userData</code></dt> <dd>Pointer to the data to pass to the function <code>func</code> once called.</dd>
</dl>
<h3 id="Returns" name="Returns">Returns</h3>
<ul> <li>Nothing.</li>
</ul>
<h3 id="Description" name="Description">Description</h3>
<p>Causes asynchronous execution of the specified function pointer on the "plug-in thread", passing in the specified user data pointer when it is called. The "plug-in thread" is the thread hosting the plug-in, which may be either the browser's main thread or the plug-in process if the plug-in is being executed <a href="/en/Plugins/Out_of_process_plugins" title="en/Plugins/Out of process plugins">out-of-process</a>.</p>
<p>It is the application's responsibility to perform any synchronization between the thread calling <code>NPN_PluginThreadAsyncCall()</code> and the thread on which the call is eventually executed. In particular, the user must ensure that the function pointer remains callable and the user data is not deallocated until the browser executes the call.</p>
<p>There are inherent race conditions between calling this function and termination of the plug-in instance. The browser might not execute calls successfully registered with this API call during plug-in termination. Plug-ins should perform appropriate synchronization with the code in their <a href="/en/NPP_Destroy" title="en/NPP Destroy"><code>NPP_Destroy()</code></a> routine to ensure correct execution and avoid memory leaks.</p>
<p>Calling <code>NPN_PluginThreadAsyncCall()</code> on the "browser main thread" or the "plug-in thread" is legal; the call to <code>NPN_PluginThreadAsyncCall()</code> returns immediately. After control returns to the browser, it is free to call the function with its argument from this thread.</p>
<h3 id="See_Also" name="See_Also">See Also</h3>
<ul> <li><a href="/en/NPP" title="en/NPP">NPP</a></li> <li><a href="/en/Plugins/Out_of_process_plugins" title="en/Plugins/Out of process plugins">Out-of-process plugins</a></li>
</ul>
Revert to this revision