Exemplo n.º 1
0
        //
        // Tries to enter the read lock, activating the specified
        // cancellers.
        //

        public bool TryEnterRead(StCancelArgs cargs) {
            OwnerEntry hint;
            int tid;

            if (FastTryEnterRead((tid = Thread.CurrentThread.ManagedThreadId), out hint)) {
                return true;
            }

            //
            // The current thread isn't a read lock owner. So, allocate an
            // entry on the lock owner table, before acquire the non-reentrant
            // r/w lock.
            //

            hint = readOwner.AllocateEntry(tid, hint);

            if (rwlock.TryEnterRead(cargs)) {
                return true;
            }

            //
            // The specified timeout expired, so remove our entry
            // from the lock owner table and return failure.
            //

            hint.Free();
            return false;
        }