Ejemplo n.º 1
0
        /// <summary>
        /// create a new table-lock
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private LockEntry CreateTabLock(ref LockContext ctx)
        {
            if (!TabLocks.TryGetValue(ctx.Index, out var list))
            {
                list = new LinkedList <LockEntry>();
                TabLocks[ctx.Index] = list;;
            }

            var tx    = ctx.Transaction;
            var entry = new LockEntry(ctx.Page, ctx.Flags, ctx.RecordCount);

            if (entry.IsWaiting)
            {
                tx.WaitLock = entry;
            }

            list.AddLast(entry);
            tx.Locks.AddLast(entry);

            entry.GNode       = list.Last;
            entry.TNode       = tx.Locks.Last;
            entry.Index       = ctx.Index;
            entry.Transaction = ctx.Transaction;
            entry.Thread      = Thread.CurrentThread.ManagedThreadId;

            return(entry);
        }
Ejemplo n.º 2
0
 internal LockEntry FindFirstTabLockEntry(TableIndex index)
 {
     return(TabLocks.TryGetValue(index, out var list) ? list.First.Value : null);
 }