Synchronized functions
Tal Liron
tal.liron at threecrickets.com
Fri Oct 11 01:45:57 PDT 2013
Thanks!
Would it be possible to add this to mozilla_compat.js so that "new
org.mozilla.javascript.Synchronizer(myFunction)" would work?
On 10/11/2013 03:31 PM, A. Sundararajan wrote:
> There is a 'sync' function in a demo application (jconsole script
> plugin). This may be of use.
>
> var sync = function(func, obj) {
> if (arguments.length < 1 || arguments.length > 2 ) {
> throw "sync(function [,object]) parameter count mismatch";
> }
>
> var syncobj = (arguments.length == 2 ? obj : this);
>
> if (!syncobj._syncLock) {
> syncobj._syncLock = new Lock();
> }
>
> return function() {
> syncobj._syncLock.lock();
> try {
> func.apply(null, arguments);
> } finally {
> syncobj._syncLock.unlock();
> }
> };
> };
>
> See also:
> https://blogs.oracle.com/nashorn/entry/nashorn_multi_threading_and_mt
>
> -Sundar
>
> On Thursday 10 October 2013 03:16 PM, Tal Liron wrote:
>> How does one create synchronized functions in Nashorn?
>>
>> Rhino has this facility:
>>
>> function myFunction() { ... }
>> myFunction = new org.mozilla.javascript.Synchronizer(myFunction)
>
More information about the nashorn-dev
mailing list