コード例 #1
0
            /// <inheritdoc />
            public void Dispose()
            {
                switch (this.action)
                {
                case CookieAction.None:
                    break;

                case CookieAction.ExitReadLock:
                    [email protected]();
                    DeadlockMonitor.ExitAcquired(this.parent.@lock, readLock);
                    break;

                case CookieAction.ExitWriteLock:
                    [email protected]();
                    DeadlockMonitor.ExitAcquired(this.parent.@lock, writeLock);
                    break;

                case CookieAction.ExitWriteAndUpgradeableReadLock:
                    [email protected]();
                    [email protected]();
                    DeadlockMonitor.ExitAcquired(this.parent.@lock, writeLock);
                    DeadlockMonitor.ExitAcquired(this.parent.@lock, upgradableReadLock);
                    break;

                case CookieAction.EnterWriteLock:
                    DeadlockMonitor.EnterWaiting(this.parent.@lock, readLock, this.parent.lockedObject);
                    DeadlockMonitor.EnterWaiting(this.parent.@lock, writeLock, this.parent.lockedObject);
                    DeadlockMonitor.EnterWaiting(this.parent.@lock, upgradableReadLock, this.parent.lockedObject);

                    if ([email protected](WarningTimeout))
                    {
                        Debug.Print("Reacquiring a write lock on {0} from thread {1} ({2}) is taking longer than expected.",
                                    this.parent.lockedObject, Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.Name);
                        DeadlockMonitor.DetectDeadlocks();
                        [email protected]();
                    }
                    DeadlockMonitor.ConvertWaitingToAcquired(this.parent.@lock, writeLock, this.parent.lockedObject);
                    DeadlockMonitor.ExitWaiting(this.parent.@lock, readLock);
                    DeadlockMonitor.ExitWaiting(this.parent.@lock, upgradableReadLock);

                    break;

                case CookieAction.ExitUpgrableReaderLock:
                    [email protected]();
                    DeadlockMonitor.ExitAcquired(this.parent.@lock, upgradableReadLock);
                    break;
                }

                this.action = CookieAction.None;

                GC.SuppressFinalize(this);
            }
コード例 #2
0
 public static extern void zfb_editCookie(int id, NativeCookie cookie, CookieAction action);
コード例 #3
0
            /// <inheritdoc />
            public void Dispose()
            {
                switch ( this.action )
                {
                    case CookieAction.None:
                        break;

                    case CookieAction.ExitReadLock:
                        [email protected]();
                        DeadlockMonitor.ExitAcquired( this.parent.@lock, readLock );
                        break;

                    case CookieAction.ExitWriteLock:
                        [email protected]();
                        DeadlockMonitor.ExitAcquired( this.parent.@lock, writeLock );
                        break;

                    case CookieAction.ExitWriteAndUpgradeableReadLock:
                        [email protected]();
                        [email protected]();
                        DeadlockMonitor.ExitAcquired( this.parent.@lock, writeLock );
                        DeadlockMonitor.ExitAcquired( this.parent.@lock, upgradableReadLock );
                        break;

                    case CookieAction.EnterWriteLock:
                        DeadlockMonitor.EnterWaiting( this.parent.@lock, readLock, this.parent.lockedObject );
                        DeadlockMonitor.EnterWaiting( this.parent.@lock, writeLock, this.parent.lockedObject );
                        DeadlockMonitor.EnterWaiting( this.parent.@lock, upgradableReadLock, this.parent.lockedObject );

                        if ( [email protected]( WarningTimeout ) )
                        {
                            Debug.Print( "Reacquiring a write lock on {0} from thread {1} ({2}) is taking longer than expected.",
                                         this.parent.lockedObject, Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.Name );
                            DeadlockMonitor.DetectDeadlocks();
                            [email protected]();
                        }
                        DeadlockMonitor.ConvertWaitingToAcquired( this.parent.@lock, writeLock, this.parent.lockedObject );
                        DeadlockMonitor.ExitWaiting( this.parent.@lock, readLock );
                        DeadlockMonitor.ExitWaiting( this.parent.@lock, upgradableReadLock );

                        break;

                    case CookieAction.ExitUpgrableReaderLock:
                        [email protected]();
                        DeadlockMonitor.ExitAcquired( this.parent.@lock, upgradableReadLock );
                        break;
                }

                this.action = CookieAction.None;

                GC.SuppressFinalize( this );
            }
コード例 #4
0
 internal Cookie( CookieAction action, ReaderWriterLockWrapper parent, StackTrace stackTrace )
 {
     this.action = action;
     this.parent = parent;
     this.stackTrace = stackTrace;
 }
コード例 #5
0
 internal Cookie(CookieAction action, ReaderWriterLockWrapper parent, StackTrace stackTrace)
 {
     this.action     = action;
     this.parent     = parent;
     this.stackTrace = stackTrace;
 }