mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
New multitouch-compatible touch system.
This commit is contained in:
parent
38d20eba9a
commit
6c09a53d55
15 changed files with 861 additions and 280 deletions
|
@ -1,25 +1,61 @@
|
|||
function SeqQueue() {
|
||||
this.queue = []
|
||||
this.seq = 0
|
||||
function SeqQueue(size, maxWaiting) {
|
||||
this.lo = 0
|
||||
this.size = size
|
||||
this.maxWaiting = maxWaiting
|
||||
this.waiting = 0
|
||||
this.list = new Array(size)
|
||||
this.locked = true
|
||||
}
|
||||
|
||||
SeqQueue.prototype.start = function(seq) {
|
||||
this.locked = false
|
||||
this.lo = seq
|
||||
this.maybeConsume()
|
||||
}
|
||||
|
||||
SeqQueue.prototype.stop = function() {
|
||||
this.locked = true
|
||||
this.maybeConsume()
|
||||
}
|
||||
|
||||
SeqQueue.prototype.push = function(seq, handler) {
|
||||
this.queue[seq] = handler
|
||||
this.maybeDequeue()
|
||||
if (seq >= this.size) {
|
||||
return
|
||||
}
|
||||
|
||||
this.list[seq] = handler
|
||||
this.waiting += 1
|
||||
this.maybeConsume()
|
||||
}
|
||||
|
||||
SeqQueue.prototype.done = function(seq, handler) {
|
||||
this.queue[seq] = handler
|
||||
this.maybeDequeue()
|
||||
}
|
||||
SeqQueue.prototype.maybeConsume = function() {
|
||||
if (this.locked) {
|
||||
return
|
||||
}
|
||||
|
||||
SeqQueue.prototype.maybeDequeue = function() {
|
||||
var handler
|
||||
while (this.waiting) {
|
||||
// Did we reach the end of the loop? If so, start from the beginning.
|
||||
if (this.lo === this.size) {
|
||||
this.lo = 0
|
||||
}
|
||||
|
||||
while ((handler = this.queue[this.seq])) {
|
||||
this.queue[this.seq] = void 0
|
||||
handler()
|
||||
this.seq += 1
|
||||
var handler = this.list[this.lo]
|
||||
// Have we received it yet?
|
||||
if (handler) {
|
||||
this.list[this.lo] = void 0
|
||||
handler()
|
||||
this.lo += 1
|
||||
this.waiting -= 1
|
||||
}
|
||||
// Are we too much behind? If so, just move on.
|
||||
else if (this.waiting >= this.maxWaiting) {
|
||||
this.lo += 1
|
||||
this.waiting -= 1
|
||||
}
|
||||
// We don't have it yet, stop.
|
||||
else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue