]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/TaskQueue.js
3 * Handle batch read / write of DOMs, currently used in SizeMonitor + PaintMonitor
5 Ext
.define('Ext.TaskQueue', {
6 requires
: 'Ext.AnimationQueue',
14 constructor: function() {
18 this.run
= Ext
.Function
.bind(this.run
, this);
19 this.watch
= Ext
.Function
.bind(this.watch
, this);
21 // iOS has a nasty bug which causes pending requestAnimationFrame to not release
22 // the callback when the WebView is switched back and forth from / to being background process
23 // We use a watchdog timer to workaround this, and restore the pending state correctly if this happens
24 // This timer has to be set as an interval from the very beginning and we have to keep it running for
25 // as long as the app lives, setting it later doesn't seem to work
27 setInterval(this.watch
, 500);
31 requestRead: function(fn
, scope
, args
) {
33 this.readQueue
.push(arguments
);
36 requestWrite: function(fn
, scope
, args
) {
38 this.writeQueue
.push(arguments
);
41 request: function(mode
) {
43 this.pendingTime
= Date
.now();
47 setTimeout(this.run
, 1);
49 requestAnimationFrame(this.run
);
55 if (this.pending
&& Date
.now() - this.pendingTime
>= 500) {
63 var readQueue
= this.readQueue
,
64 writeQueue
= this.writeQueue
,
71 if (writeQueue
.length
> 0) {
78 if (readQueue
.length
> 0) {
83 var tasks
= queue
.slice(),
84 i
, ln
, task
, fn
, scope
;
88 for (i
= 0, ln
= tasks
.length
; i
< ln
; i
++) {
93 if (typeof fn
== 'string') {
97 if (task
.length
> 2) {
98 fn
.apply(scope
, task
[2]);
107 if (request
!== null) {
108 this.request(request
);