fixed really nasty bug, requestTransaction was called synchronously

This commit is contained in:
Kevin Jahns
2015-07-17 15:04:00 +02:00
parent 4563ccc98e
commit ebc628adfc
7 changed files with 99 additions and 14 deletions

View File

@@ -120,17 +120,31 @@ Y.Memory = (function(){ //eslint-disable-line no-unused-vars
super(y);
this.os = new RBTree();
this.ss = {};
this.waitingTransactions = [];
this.transactionInProgress = false;
}
requestTransaction (makeGen : Function) {
var t = new Transaction(this);
var gen = makeGen.call(t);
var res = gen.next();
while(!res.done){
if (res.value === "transaction") {
res = gen.next(t);
} else {
throw new Error("You must not yield this type. (Maybe you meant to use 'yield*'?)");
}
requestTransaction (_makeGen : Function) {
if (!this.transactionInProgress) {
this.transactionInProgress = true;
window.setTimeout(() => {
var makeGen = _makeGen;
while (makeGen != null) {
var t = new Transaction(this);
var gen = makeGen.call(t);
var res = gen.next();
while(!res.done){
if (res.value === "transaction") {
res = gen.next(t);
} else {
throw new Error("You must not yield this type. (Maybe you meant to use 'yield*'?)");
}
}
makeGen = this.waitingTransactions.shift();
}
this.transactionInProgress = false;
}, 0);
} else {
this.waitingTransactions.push(_makeGen);
}
}
*removeDatabase () {