flymis/WebRoot/dojojs/src/lang/timing/Streamer.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.lang.timing.Streamer");
dojo.require("dojo.lang.timing.Timer");
dojo.lang.timing.Streamer = function(
/* function */input,
/* function */output,
/* int */interval,
/* int */minimum,
/* array */initialData
){
// summary
// Streamer will take an input function that pushes N datapoints into a
// queue, and will pass the next point in that queue out to an
// output function at the passed interval; this way you can emulate
// a constant buffered stream of data.
// input: the function executed when the internal queue reaches minimumSize
// output: the function executed on internal tick
// interval: the interval in ms at which the output function is fired.
// minimum: the minimum number of elements in the internal queue.
var self = this;
var queue = [];
// public properties
this.interval = interval || 1000;
this.minimumSize = minimum || 10; // latency usually == interval * minimumSize
this.inputFunction = input || function(q){ };
this.outputFunction = output || function(point){ };
// more setup
var timer = new dojo.lang.timing.Timer(this.interval);
var tick = function(){
self.onTick(self);
if(queue.length < self.minimumSize){
self.inputFunction(queue);
}
var obj = queue.shift();
while(typeof(obj) == "undefined" && queue.length > 0){
obj = queue.shift();
}
// check to see if the input function needs to be fired
// stop before firing the output function
// TODO: relegate this to the output function?
if(typeof(obj) == "undefined"){
self.stop();
return;
}
后面还有 39 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。