public static LockInfo FindLockInfo(object codeLock)
        {
            LockInfo info = null;

            lock (LockInfos)
            {
                if (LockInfos.TryGetValue(codeLock, out info))
                {
                }
            }
            return(info);
        }
Example #2
0
        protected void Initialize(ulong startAddress)
        {
            // any Swappables in the same 4G range are assumed to conflict
            var lockkey = (uint)(startAddress >> 32);

            _lockkey = lockkey;
            if (lockkey == 0)
            {
                throw new NullReferenceException();
            }
            _currentLockInfo = LockInfos.GetOrAdd(_lockkey, new LockInfo {
                Sync = new object()
            });
        }
        public static LockInfo ExitUserThread(string lockType, LockInfo lockInfo, object codeLock)
        {
            lock (LockInfos)
            {
                LockInfo info = FindLockInfo(codeLock);

                if (info != null)
                {
                    if (info.IsLockerCurrentThread)
                    {
                        if (codeLock != null)
                        {
                            info.needsUnlock--;
                            //if (info.needsUnlock==0)
                            {
                                info.wasUnlocked++;
                            }

                            if (info.needsUnlock == 0)
                            {
                                info.MoreInfo("Exiting " + lockType);
                                LockInfos.Remove(info);
                            }
                            else
                            {
                                info.MoreInfo("departing " + lockType);
                            }
                        }
                    }
                }
                else
                {
                    writeDebugLine("Cannot exit lock " + lockType + " " + lockInfo);
                }
                return(info);
            }
        }