started refactoring the Memory db

This commit is contained in:
Kevin Jahns
2015-10-15 18:54:29 +02:00
parent 181595293f
commit aff10fa4db
9 changed files with 249 additions and 186 deletions

View File

@@ -275,5 +275,28 @@ class AbstractDatabase {
yield* t._changed(transaction, Y.utils.copyObject(op))
}
}
getNextRequest () {
if (this.waitingTransactions.length === 0) {
this.transactionInProgress = false
return null
} else {
return this.waitingTransactions.shift()
}
}
requestTransaction (makeGen, callImmediately) {
if (!this.transactionInProgress) {
this.transactionInProgress = true
if (callImmediately) {
this.transact(makeGen)
} else {
var self = this
setTimeout(function () {
self.transact(makeGen)
}, 0)
}
} else {
this.waitingTransactions.push(makeGen)
}
}
}
Y.AbstractDatabase = AbstractDatabase