예제 #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
파일: Log.cs 프로젝트: zdmta/openrpa
 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
파일: Pool.cs 프로젝트: aslyr/BeetlexSample
 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
파일: Pool.cs 프로젝트: RocChing/ChatServer
 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);
 }