[IMP] Moved Mutex class to openerpframework.js

bzr revid: nicolas.vanhoren@openerp.com-20130806131746-l43mz6aos7eupehm
This commit is contained in:
niv-openerp 2013-08-06 15:17:46 +02:00
parent e6e5fcde1e
commit d3a2c47fb1
2 changed files with 16 additions and 15 deletions

View File

@ -612,21 +612,7 @@ $.fn.openerpBounce = function() {
};
/** Jquery extentions */
$.Mutex = (function() {
function Mutex() {
this.def = $.Deferred().resolve();
}
Mutex.prototype.exec = function(action) {
var current = this.def;
var next = this.def = $.Deferred();
return current.then(function() {
return $.when(action()).always(function() {
next.resolve();
});
});
};
return Mutex;
})();
$.Mutex = openerp.Mutex;
$.async_when = function() {
var async = false;

View File

@ -1222,6 +1222,21 @@ openerp.qweb.default_dict = {
'_t' : openerp._t
};
openerp.Mutex = openerp.Class.extend({
init: function() {
this.def = $.Deferred().resolve();
},
exec: function(action) {
var current = this.def;
var next = this.def = $.Deferred();
return current.then(function() {
return $.when(action()).always(function() {
next.resolve();
});
});
}
});
openerp.declare = declare;
return openerp;