Ejemplo n.º 1
0
        protected override void InternalEnqueue(Action action)
        {
            AggressiveSpinWait spinWait = default;

            while (_queue.IsFull)
            {
                spinWait.SpinOnce();
            }

            bool lockTaken = false;

            try
            {
                _spinLock.Enter(ref lockTaken);

                _queue.Enqueue(action);

                if (_flushPending)
                {
                    return;
                }

                _flushPending = true;
                ThreadPool.QueueUserWorkItem(Flush, null);
            }
            finally
            {
                if (lockTaken)
                {
                    _spinLock.Exit(false);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void InternalEnqueue(Action action)
        {
            AggressiveSpinWait spinWait = default;

            //SpinWait spinWait = new SpinWait();
            while (_queue.IsFull)
            {
                spinWait.SpinOnce();
            }

            bool lockTaken = false;

            try
            {
                _spinLock.Enter(ref lockTaken);

                _queue.Enqueue(action);

                if (_flushPending)
                {
                    return;
                }

                _flushPending = true;
                _             = _taskFactory.StartNew(_flushCache);
            }
            finally
            {
                if (lockTaken)
                {
                    _spinLock.Exit(false);
                }
            }
        }
Ejemplo n.º 3
0
        protected override void InternalEnqueue(Action action)
        {
            AggressiveSpinWait spinWait = default;

            while (_queue.IsFull)
            {
                spinWait.SpinOnce();
            }

            lock (_lock)
            {
                _queue.Enqueue(action);

                if (_flushPending)
                {
                    return;
                }

                _flushPending = true;
                _             = _taskFactory.StartNew(_flushCache);
            }
        }