Esempio n. 1
0
        internal SocketLockToken GetSuspendingLock(Action onReceivingAborted, Action onSendingAborted)
        {
            SocketLockToken result = SuspendLock();

            AbortReceiving(onReceivingAborted);
            AbortSending(onSendingAborted);
            return(result);
        }
Esempio n. 2
0
        internal void UnlockSocket(SocketLockToken token) // TODO : доделать
        {
            switch (token.type)
            {
            case LockType.Receive:
                if (Interlocked.Decrement(ref receivingLockersCount) == 0)
                {
                    socketReceiveLocked = false;
                    if (receiveKernelWaitingsCount != 0)
                    {
                        receiveARE.Set();
                    }
                }
                break;

            case LockType.Send:
                SocketSendLockToken sendToken = token as SocketSendLockToken;
                if (sendToken.IsHardLocked)
                {
                    if (Interlocked.Decrement(ref sendingHardLockersCount) == 0)
                    {
                        socketSendHardLocked = false;
                    }
                }
                if (Interlocked.Decrement(ref sendingLockersCount) == 0)
                {
                    socketSendSoftLocked = false;
                    if (sendKernelWaitingsCount != 0)
                    {
                        sendARE.Set();
                    }
                }
                break;

            case LockType.Suspend:
                if (Interlocked.Decrement(ref receivingLockersCount) == 0)
                {
                    socketReceiveLocked = false;
                    if (receiveKernelWaitingsCount != 0)
                    {
                        receiveARE.Set();
                    }
                }
                if (Interlocked.Decrement(ref sendingHardLockersCount) == 0)
                {
                    socketSendHardLocked = false;
                }
                if (Interlocked.Decrement(ref sendingLockersCount) == 0)
                {
                    socketSendSoftLocked = false;
                    if (sendKernelWaitingsCount != 0)
                    {
                        sendARE.Set();
                    }
                }
                break;
            }
        }
Esempio n. 3
0
        internal SocketLockToken GetSuspendingLock(bool abortCurrentOperations)
        {
            SocketLockToken result = SuspendLock();

            if (abortCurrentOperations)
            {
                AbortReceiving();
                AbortSending();
            }
            return(result);
        }