mozilla

Revision 90131 of NPN_PluginThreadAsyncCall

  • Revision slug: NPN_PluginThreadAsyncCall
  • Revision title: NPN_PluginThreadAsyncCall
  • Revision id: 90131
  • Created:
  • Creator: Jst
  • Is current revision? No
  • Comment New page: <breadcrumbs></breadcrumbs><title-override>NPN_PluginThreadAsyncCall</title-override> {{np-browser-api}} ==Summary== Thread safe way to request that the browser calls a plugin function on...
Tags: 

Revision Content

{{wiki.template('Np-browser-api')}}

Summary

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

Syntax

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

Parameters

The function has the following parameters:

npp
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 "plugin thread", passing in the specified user data pointer when it is called. (The "plugin thread" means the thread hosting the plug-in, which today is the browser window's UI thread, though this might change in the future.)

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 plugin instance. The browser might not execute calls successfully registered with this API call during plugin termination. Plugins 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 "plugin 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

NPP

Revision Source

<p>
{{wiki.template('Np-browser-api')}}
</p>
<h3 name="Summary">Summary</h3>
<p>Thread safe way to request that the browser calls a plugin function on the browser or plugin thread (the thread on which the plugin was initiated).
</p>
<h3 name="Syntax">Syntax</h3>
<pre>#include &lt;npapi.h&gt;
 
void
NPN_PluginThreadAsyncCall(NPP plugin,
                          void (*func)(void *),
                          void *userData);
</pre>
<h3 name="Parameters">Parameters</h3>
<p>The function has the following parameters:
</p>
<dl><dt>npp
</dt><dd>Pointer to the current plug-in instance.
</dd></dl>
<dl><dt>func
</dt><dd>Pointer to the function to call on the correct thread.
</dd></dl>
<dl><dt>userData
</dt><dd>Pointer to the data to pass to the function <code>func</code> once called.
</dd></dl>
<h3 name="Returns">Returns</h3>
<ul><li> Nothing
</li></ul>
<h3 name="Description">Description</h3>
<p>Causes asynchronous execution of the specified function pointer on the
"plugin thread", passing in the specified user data pointer when it is
called. (The "plugin thread" means the thread hosting the plug-in,
which today is the browser window's UI thread, though this might
change in the future.)
</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 plugin instance. The browser might not execute
calls successfully registered with this API call during plugin
termination. Plugins should perform appropriate synchronization with
the code in their <code>NPP_Destroy()</code> routine to ensure correct execution and avoid memory leaks.
</p><p>Calling <code>NPN_PluginThreadAsyncCall()</code> on the "browser main thread" or
the "plugin 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 name="See_Also">See Also</h3>
<p><a href="en/NPP">NPP</a>
</p>
Revert to this revision