mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add a Utils.lock as a sync. version of Wrap.localLock.
This commit is contained in:
parent
042c177ad0
commit
2f189ad5a8
@ -152,6 +152,7 @@ function WeaveSvc() {
|
||||
}
|
||||
WeaveSvc.prototype = {
|
||||
|
||||
_lock: Utils.lock,
|
||||
_localLock: Wrap.localLock,
|
||||
_catch: Utils.catch,
|
||||
_catchAll: Wrap.catchAll,
|
||||
|
@ -71,6 +71,27 @@ let Utils = {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Wrap a function to call lock before calling the function then unlock.
|
||||
*
|
||||
* @usage MyObj._lock = Utils.lock;
|
||||
* MyObj.foo = function() { this._lock(func)(); }
|
||||
*/
|
||||
lock: function Utils_lock(func) {
|
||||
let thisArg = this;
|
||||
return function WrappedLock() {
|
||||
if (!thisArg.lock())
|
||||
throw "Could not acquire lock";
|
||||
|
||||
try {
|
||||
return func.call(thisArg);
|
||||
}
|
||||
finally {
|
||||
thisArg.unlock();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Wrap functions to notify when it starts and finishes executing or if it got
|
||||
* an error. The message is a combination of a provided prefix and local name
|
||||
|
Loading…
Reference in New Issue
Block a user