Last change
on this file since 20021 was 16789, checked in by tbretz, 11 years ago |
Debugging output seems not needed anymore.
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | function Handler(name)
|
---|
4 | {
|
---|
5 | this.name = name;
|
---|
6 | this.array = [];
|
---|
7 |
|
---|
8 | this.add = function(func)
|
---|
9 | {
|
---|
10 | this.array.push(func);
|
---|
11 | //console.out(this.name+":add [N="+this.array.length+"]");
|
---|
12 | }
|
---|
13 |
|
---|
14 | this.run = function(timeout)
|
---|
15 | {
|
---|
16 | console.out(this.name+":start");
|
---|
17 |
|
---|
18 | var rc = [];
|
---|
19 |
|
---|
20 | var start = new Date();
|
---|
21 | while (!timeout || (new Date()-start)<timeout)
|
---|
22 | {
|
---|
23 | var done = true;
|
---|
24 |
|
---|
25 | //rc = rc.map(this.array[i]);
|
---|
26 | //
|
---|
27 | //rc.forEach(function(el){ done &= el && el.length==0;);
|
---|
28 |
|
---|
29 | for (var i=0; i<this.array.length; i++)
|
---|
30 | {
|
---|
31 | rc[i] = this.array[i](rc[i]);
|
---|
32 | if (rc[i]===undefined || rc[i].length>0)
|
---|
33 | done = false;
|
---|
34 | }
|
---|
35 |
|
---|
36 | if (done)
|
---|
37 | {
|
---|
38 | console.out(this.name+":success [time="+(new Date()-start)+"ms]");
|
---|
39 | return true;
|
---|
40 | }
|
---|
41 |
|
---|
42 | v8.sleep();
|
---|
43 | }
|
---|
44 |
|
---|
45 | console.out(this.name+":timeout ["+timeout+"ms]");
|
---|
46 | return false;
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.