Table of Contents | Previous
| Next
| Index
Provides a way to lock a critical section of code.
The Lock
constructor:
Lock();
None.
Failure to construct a new Lock
object indicates an internal JavaScript error, such as out of memory.
In addition, this object inherits the watch
and unwatch
methods from Object
.
project.lock
, project.unlock
, server.lock
, server.unlock
lock(timeout)
True if it succeeds in obtaining the lock within the specified timeout. False if it did not obtain the lock.
You can obtain a lock for an object to ensure that different clients do not access a critical section of code simultaneously. When an application locks an object, other client requests must wait before they can lock the object.
Note that this mechanism requires voluntary compliance by asking for the lock in the first place.
Lock.unlock
, Lock.isValid
, project.lock
, server.lock
Specifies the function that creates an object's prototype. Note that the value of this property is a reference to the function itself, not a string containing the function's name.
See Object.constructor
.
Verifies that this Lock
object was properly constructed.
isValid()
None.
True, if this object was properly constructed; otherwise, false.
It is very rare that your Lock
object would not be properly constructed. This happens only if the runtime engine runs out of system resources while creating the object.
This code creates a Lock
object and verifies that nothing went wrong creating it:
// construct a new Lock and save in project
project.ordersLock = new Lock();
if (! project.ordersLock.isValid()) {
// Unable to create a Lock. Redirect to error page
...
}
Lock.lock
, Lock.unlock
Obtains the lock. If someone else has the lock, this method blocks until it can get the lock, the specified timeout period has elapsed, or an error occurs.
Represents the prototype for this class. You can use the prototype to add properties or methods to all instances of a class. For information on prototypes, see Function.prototype
.
Releases the lock.
unlock()
None.
False if it fails; otherwise, true. Failure indicates an internal JavaScript error or that you attempted to unlock a lock that you don't own.
If you unlock a lock that is unlocked, the resulting behavior is undefined.
Lock.lock
, Lock.isValid
, project.unlock
, server.unlock
Table of Contents | Previous
| Next
| Index
Last Updated: 11/13/98 10:23:22
Copyright � 1998
Netscape Communications Corporation