1 jls.loader.provide('jls.lang.Lock'); 2 3 jls.lang.Lock = jls.lang.Class.create(/** @lends jls.lang.Lock.prototype */ 4 { 5 /** 6 * Creates a lock. A lock provides a means to control access to a shared resource by multiple threads. 7 * 8 * @constructs 9 * @class A lock provides a means to control access to a shared resource by multiple threads. 10 * Locking prevents access to some resource, such as a piece of shared data: that is, it enforces mutual exclusion. 11 */ 12 initialize : function() { 13 this._no = new _native.core.Lock(); 14 }, 15 /** 16 * Closes this lock. 17 * 18 * @returns {jls.lang.Lock} This lock. 19 */ 20 close : function() { 21 this._no.close(); 22 return this; 23 }, 24 /** 25 * Acquires the lock. 26 * 27 * @returns {jls.lang.Lock} This lock. 28 */ 29 lock : function() { 30 this._no.lock(); 31 return this; 32 }, 33 /** 34 * Releases the lock. 35 * 36 * @returns {jls.lang.Lock} This lock. 37 */ 38 unlock : function() { 39 this._no.unlock(); 40 return this; 41 } 42 }); 43 44