Beispiel #1
0
        // This is called on the libuv event loop
        private void WriteAllPending()
        {
            WriteContext writingContext = null;

            if (Monitor.TryEnter(_contextLock))
            {
                _postingWrite = false;

                if (_nextWriteContext != null)
                {
                    writingContext    = _nextWriteContext;
                    _nextWriteContext = null;
                }
                else
                {
                    _ongoingWrites--;
                }

                Monitor.Exit(_contextLock);
            }
            else
            {
                ScheduleWrite();
            }

            if (writingContext != null)
            {
                writingContext.DoWriteIfNeeded();
            }
        }