java.lang.Object
org.htmlunit.corejs.javascript.Delegator
org.htmlunit.corejs.javascript.Synchronizer
- All Implemented Interfaces:
Callable,Constructable,Function,PropHolder<Scriptable>,Scriptable,SymbolScriptable
This class provides support for implementing Java-style synchronized methods in Javascript.
Synchronized functions are created from ordinary Javascript functions by the
Synchronizer constructor, e.g. new Packages.org.htmlunit.corejs.javascript.Synchronizer(fun) .
The resulting object is a function that establishes an exclusive lock on the this object
of its invocation.
The Rhino shell provides a short-cut for the creation of synchronized methods:
sync(fun) has the same effect as calling the above constructor.
- Author:
- Matthias Radestock
- See Also:
-
Field Summary
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionSynchronizer(Scriptable obj) Create a new synchronized function from an existing one.Synchronizer(Scriptable obj, Object syncObject) Create a new synchronized function from an existing one using an explicit object as synchronization object. -
Method Summary
Methods inherited from class org.htmlunit.corejs.javascript.Delegator
construct, delete, delete, delete, get, get, get, getClassName, getDefaultValue, getDelegee, getIds, getParentScope, getPrototype, has, has, has, hasInstance, newInstance, put, put, put, setDelegee, setParentScope, setPrototypeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Constructable
constructMethods inherited from interface org.htmlunit.corejs.javascript.Function
getDeclarationScope, isConstructorMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
getAncestor
-
Constructor Details
-
Synchronizer
Create a new synchronized function from an existing one.- Parameters:
obj- the existing function
-
Synchronizer
Create a new synchronized function from an existing one using an explicit object as synchronization object.- Parameters:
obj- the existing functionsyncObject- the object to synchronized on
-
-
Method Details
-
call
Description copied from interface:FunctionCall the function.Note that the array of arguments is not guaranteed to have length greater than 0.
- Specified by:
callin interfaceCallable- Specified by:
callin interfaceFunction- Overrides:
callin classDelegator- Parameters:
cx- the current Context for this threadscope- the scope to execute the function relative to. This is set to the value returned by getParentScope() except when the function is called from a closure.thisObj- the JavaScriptthisobjectargs- the array of arguments- Returns:
- the result of the call
- See Also:
-