Apq.Threading.js

Apq.namespace( "Apq.Threading" );

if( !Apq.Threading.Thread )
{
 Apq.Threading.Thread = Apq.Class( "Apq.Threading.Thread" );

 /// <t=0>启动延时时间</t>
 /// <m=true>是否允许多次排队</m>
 Apq.Threading.Thread.prototype.ctor = function( ThreadStart, t, args, o, m ){
  this.t = t || 0;
  this.ThreadStart = ThreadStart;
  this.args = args;
  this.o = o;
  this.m = m == null ? true : m;
  this.ids = []; // 排队号码集合
 };
 
 Apq.Threading.Thread.prototype.Enqueue = function(){
  if( !this.m && this.ids.length )
  {
   throw new Error( -1, "该线程不允许重复排队" );
  }
  var id = Apq.setTimeout( this.t, this.ThreadStart, arguments.length ? arguments : this.args, this.o );
  this.ids.push( id );
  return id;
 };
 
 Apq.Threading.Thread.prototype.Dequeue = function( id ){
  id = id || this.ids.concat();
  
  if( id instanceof Array )
  {
   if( id.length )
   {
    for( var i = 0; i < id.length; i++ )
    {
     this.Dequeue( id[i] );
    }
   }
   else
   {
    this.Dequeue();
   }
  }
  else if( this.ids.Contains( id ) )
  {
   clearTimeout( id );
   this.ids.Remove( id );
  }
 };
}

转载于:https://www.cnblogs.com/Apq/archive/2006/06/14/425521.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值