void InitEventArgs() { for (var i = 0; i < 1000; i++) { freeEventArgs.Push(new SocketAsyncEventArgs()); } }
public ProtocolBufferPool() { for (int i = 0; i < 1000; i++) { mPool.Push(CreateBuffer()); } }
public static void ToPool(T obj) { if (!(obj is null)) { _stack.Push(obj); } }
//回收对对象 void PushBackEventArgs(SocketAsyncEventArgs item) { if (item == null) { throw new ArgumentNullException("Items added to a SocketAsyncEventArgsPool cannot be null"); } poolEventArgs.Push(item); }
public void Push(SocketManager client) { if (client != null) { if (client.Client.Connected) { mClients.Push(client); } } }
/// <summary> /// Puts the specified item in the pool. /// Is the 'MaxCapacity' has been reached the item is ignored. /// If a Default Intance Dispose method was provided, it will be called for the ignored item. /// </summary> public static void Put(T item) { // add to pool if it is not full if (m_bag.Count < MaxCapacity) { m_bag.Push(item); } else if (DefaultInstanceDispose != null) { DefaultInstanceDispose(item); } }
public void Push(T data) { int value = System.Threading.Interlocked.Increment(ref mCount); if (value < mMaxItems) { mQueues.Push(data); } else { System.Threading.Interlocked.Decrement(ref mCount); } }
public async override void Run(bool runChildren) { fileReadCompleted = false; string file = FileName.Convert(this); if (string.IsNullOrEmpty(file)) { file = GetText(); } if (System.IO.File.Exists(file) == false) { ReportManage.ErrReport(this, "Fileが見つかりません「" + file + "」"); return; } cancellationTokenSource = new CancellationTokenSource(); var task = Task.Factory.StartNew(() => { List <string> list = new List <string>(BlockSize); foreach (var item in System.IO.File.ReadLines(FileName.Convert(this))) { if (cancellationTokenSource.Token.IsCancellationRequested) { break; } bool flag = true; do { if (q.Count < MaxBlock) { list.Add(item); if (list.Count > BlockSize) { q.Push(list.ToArray()); list.Clear(); } flag = false; break; } else { Task.Delay(3).Wait(); } }while (flag); } fileReadCompleted = true; }, cancellationTokenSource.Token); base.Run(runChildren); }
public bool Push(T data) { int value = System.Threading.Interlocked.Increment(ref mCount); if (value < mMaxItems) { mQueues.Push(data); return(true); } else { System.Threading.Interlocked.Decrement(ref mCount); return(false); } }
void PushBackLinks(LinkInfo link) { try { link.Socket.Close(); } catch (Exception err) { } link.Socket = null; link.Handle = 0; poolLinks.Push(link); }
public void Push(TcpClient client) { var value = System.Threading.Interlocked.Increment(ref mPoolConnectins); if (value > mMinConnections) { System.Threading.Interlocked.Decrement(ref mPoolConnectins); System.Threading.Interlocked.Decrement(ref mConnections); client.DisConnect(); } else { mPools.Push(client); } }
public SunburstDrillDownManager(IEnumerable <DataItem> orignal) { this.Orignal = orignal.ToArray(); this.CurrentItems = this.Orignal; History = new System.Collections.Concurrent.ConcurrentStack <SunburstDrillDownHistory>(); History.Push( new SunburstDrillDownHistory() { Items = this.CurrentItems, } ); if (OnDrillDownChanged != null) { this.OnDrillDownChanged(this, new EventArgs()); } }
void InitPools() { _ReadBufferSize = option.ReadBufSize; _SendBufferSize = option.WriteBufSize; poolEventArgs = new System.Collections.Concurrent.ConcurrentStack <SocketAsyncEventArgs>(); for (var i = 0; i < option.ListenLinkBufSize * 2; i++) { var args = new SocketAsyncEventArgs(); args.Completed += OnCompleted; poolEventArgs.Push(args); } poolLinks = new System.Collections.Concurrent.ConcurrentStack <LinkInfo>(); for (var i = 0; i < option.ListenLinkBufSize; i++) { poolLinks.Push(GetFreeLink()); } }
public static void FunctionIndent(string cls, string func, string message = "") { Indent++; // functions.Push(cls + "." + func); functions.Push(func); if (!Config.local.log_to_file) { return; } if (string.IsNullOrEmpty(message)) { LogLine(string.Join("::", functions.Reverse()) + "::BEGIN", "Func"); //LogLine(string.Format("[{0}][{1}][{2}]::BEGIN", cls, func, Indent), "Func"); } else { LogLine(string.Join("::", functions.Reverse()) + " " + message + "::BEGIN", "Func"); //LogLine(string.Format("[{0}][{1}][{2}]::BEGIN:{3}", cls, func, Indent, message), "Func"); } }
public IEnumerable <OUT> Select <OUT>(Func <T, OUT> action) { var c = new CountdownEvent(_maxDOP); var ret = new System.Collections.Concurrent.ConcurrentStack <OUT>(); var ie = _items.GetEnumerator(); for (int i = 0; i < _maxDOP; i++) { Task.Factory.StartNew(delegate { try { T current = default(T); while (true) { lock (ie) { if (!ie.MoveNext()) { break; } current = ie.Current; } ret.Push(action(current)); } } finally { c.Signal(1); } }, _islongrunnig ? TaskCreationOptions.LongRunning : TaskCreationOptions.None); } ; c.Wait(); return(ret); }
public void Push(T data) { mQueues.Push(data); }
public void Push(ICall call) { _stack.Push(call); }
public static void Push(SerializerExpand jsonWriterExpand) { mPools.Push(jsonWriterExpand); }
public void Push(IBuffer item) { Interlocked.Increment(ref mCount); item.Pool = null; mPool.Push(item); }
public static void Push(LineBuffer value) { LineBUfferPool.Push(value); }
public void Push(IBuffer item) { mPool.Push(item); }
public void Push(byte[] data) { mPools.Push(data); }
public void Add(T value) { _timestamped.Push(value); }
static void SaveRelativeDirectory() { mOldRelativeDirectories.Push(FileManager.RelativeDirectory); }
public void PutObject(T obj) { objects.Push(obj); }
private void ReuseRecvSocketAsyncEventArgs(SocketAsyncEventArgs args) { freeRecvEventArgs.Push(args); }