Пример #1
0
 void InitEventArgs()
 {
     for (var i = 0; i < 1000; i++)
     {
         freeEventArgs.Push(new SocketAsyncEventArgs());
     }
 }
Пример #2
0
 public ProtocolBufferPool()
 {
     for (int i = 0; i < 1000; i++)
     {
         mPool.Push(CreateBuffer());
     }
 }
Пример #3
0
 public static void ToPool(T obj)
 {
     if (!(obj is null))
     {
         _stack.Push(obj);
     }
 }
Пример #4
0
 //回收对对象
 void PushBackEventArgs(SocketAsyncEventArgs item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("Items added to a SocketAsyncEventArgsPool cannot be null");
     }
     poolEventArgs.Push(item);
 }
Пример #5
0
 public void Push(SocketManager client)
 {
     if (client != null)
     {
         if (client.Client.Connected)
         {
             mClients.Push(client);
         }
     }
 }
Пример #6
0
 /// <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);
     }
 }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        void PushBackLinks(LinkInfo link)
        {
            try
            {
                link.Socket.Close();
            }
            catch (Exception err)
            {
            }

            link.Socket = null;
            link.Handle = 0;

            poolLinks.Push(link);
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
        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());
            }
        }
Пример #13
0
        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());
            }
        }
Пример #14
0
 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");
     }
 }
Пример #15
0
        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);
        }
Пример #16
0
 public void Push(T data)
 {
     mQueues.Push(data);
 }
Пример #17
0
 public void Push(ICall call)
 {
     _stack.Push(call);
 }
Пример #18
0
 public static void Push(SerializerExpand jsonWriterExpand)
 {
     mPools.Push(jsonWriterExpand);
 }
Пример #19
0
 public void Push(IBuffer item)
 {
     Interlocked.Increment(ref mCount);
     item.Pool = null;
     mPool.Push(item);
 }
Пример #20
0
 public static void Push(LineBuffer value)
 {
     LineBUfferPool.Push(value);
 }
Пример #21
0
 public void Push(IBuffer item)
 {
     mPool.Push(item);
 }
Пример #22
0
 public void Push(byte[] data)
 {
     mPools.Push(data);
 }
Пример #23
0
 public void Add(T value)
 {
     _timestamped.Push(value);
 }
Пример #24
0
 static void SaveRelativeDirectory()
 {
     mOldRelativeDirectories.Push(FileManager.RelativeDirectory);
 }
Пример #25
0
 public void PutObject(T obj)
 {
     objects.Push(obj);
 }
Пример #26
0
 private void ReuseRecvSocketAsyncEventArgs(SocketAsyncEventArgs args)
 {
     freeRecvEventArgs.Push(args);
 }