Commit | Line | Data |
---|---|---|
5e0cbfb0 PP |
1 | --- |
2 | id: channel-switch-timer | |
3 | --- | |
4 | ||
5 | The _switch timer_ period is another important configurable feature of | |
6 | channels to ensure periodic sub-buffer flushing. | |
7 | ||
8 | When the _switch timer_ fires, a sub-buffer switch happens. This timer | |
9 | may be used to ensure that event data is consumed and committed to | |
10 | trace files periodically in case of a low event throughput: | |
11 | ||
12 | <script type="text/javascript"> | |
3c3588a3 | 13 | document.write('<div class="anim img img-50" id="docsvg-channel-switch-timer"></div>'); |
5e0cbfb0 PP |
14 | |
15 | $(document).ready(function() { | |
16 | var doc = SVG('docsvg-channel-switch-timer'); | |
17 | ||
18 | doc.viewbox(0, 0, 2, 2); | |
19 | ||
20 | var div = 4; | |
21 | var evDur = 1000; | |
22 | var rb = rbBuildStd(doc, div, 0.97); | |
23 | var switchText = doc.text('Switch!'); | |
24 | ||
25 | switchText.font({ | |
26 | 'size': 0.1, | |
27 | 'weight': 'bold' | |
28 | }); | |
29 | switchText.center(1, 1); | |
30 | switchText.attr({ | |
31 | 'opacity': 0, | |
32 | 'fill': '#b02b2c' | |
33 | }); | |
34 | ||
35 | var curSubBuf = 0; | |
36 | var totalEvents = 0; | |
37 | var onEventAdded = function() { | |
38 | totalEvents++; | |
39 | ||
40 | var curSubBufEvCount = rb.getSubBufEvCount(curSubBuf % div); | |
41 | ||
42 | if (totalEvents >= 4) { | |
43 | // switch timer fires | |
44 | switchText.attr({ | |
45 | 'opacity': 1 | |
46 | }); | |
47 | switchText.animate(500, '<>', 1000).attr({ | |
48 | 'opacity': 0 | |
49 | }); | |
50 | rb.markSubBuf(curSubBuf % div, 'full'); | |
51 | ||
52 | var lastFullSubBuf = curSubBuf; | |
53 | ||
54 | setTimeout(function() { | |
55 | rb.consumeSubBuf(lastFullSubBuf % div); | |
56 | }, 3000); | |
57 | totalEvents = 0; | |
58 | curSubBuf++; | |
59 | rb.markSubBuf(curSubBuf % div, 'cur'); | |
60 | } | |
61 | ||
62 | rb.addEvent(curSubBuf % div, evDur, onEventAdded); | |
63 | }; | |
64 | ||
5e0cbfb0 | 65 | rb.markSubBuf(0, 'cur'); |
5e0cbfb0 | 66 | rb.getGroup().move(1, 1); |
3c3588a3 PP |
67 | rbSetParentPlayIcon(doc, function() { |
68 | rb.addEvent(0, evDur, onEventAdded); | |
69 | }); | |
5e0cbfb0 PP |
70 | }); |
71 | </script> | |
72 | ||
73 | <noscript> | |
74 | <div class="err"> | |
75 | <p> | |
76 | <span class="t">Oops!</span>JavaScript must be enabled in | |
77 | order to view animations. | |
78 | </p> | |
79 | </div> | |
80 | </noscript> | |
81 | ||
82 | It's also convenient when big sub-buffers are used to cope with | |
83 | sporadic high event throughput, even if the throughput is normally | |
84 | lower. |