예제 #1
0
 private bool canGoTroughOrPush(GameObject collidingWith, Vector2 direction)
 {
     if (collidingWith)
     {
         BlockingObject blockingObject = collidingWith.GetComponent <BlockingObject>();
         if (blockingObject)
         {
             if (blockingObject.CanBePushed)
             {
                 float pushMoveSpeed = blockingObject.tryToPush(direction);
                 if (pushMoveSpeed < 0)
                 {
                     return(false);
                 }
                 else
                 {
                     oldMoveSpeed = moveSpeed;
                     moveSpeed    = pushMoveSpeed;
                     return(true);
                 }
             }
             return(blockingObject.CanBeTraversed);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true); // Is not colliding with anything
     }
 }
예제 #2
0
 /// <summary>
 /// Create instance of our version BlockingObject.
 /// </summary>
 /// <param name="bo">Instance of BlockingObject from ClrHeap.</param>
 /// <param name="blockInfoNdx">Index of the owners,waiters information.</param>
 /// <param name="typeId">Type of this object.</param>
 public ClrtBlkObject(BlockingObject bo, int blockInfoNdx, int typeId)
 {
     _address      = bo.Object;
     _recursionCnt = bo.RecursionCount;
     _blkReason    = bo.Reason;
     _taken        = bo.Taken;
     _index        = blockInfoNdx;
     _typeId       = typeId;
 }
예제 #3
0
        public LockConvoyIssue(BlockingObject blockingObject)
        {
            Title = $"Lock convoy of {blockingObject.Waiters.Count} waiting and one locking threads";

            var objRef = blockingObject.Object;

            Message = string.Join("\n", new[]
            {
                $"Lock convoy to object ref [{objRef}] of type {blockingObject.Owner.Runtime.Heap.GetObjectType(objRef)}",
                $"Locking thread id [{blockingObject.Owner.OSThreadId}]",
                "Waiting threads ids:"
            }
                                  .Concat(blockingObject.Waiters
                                          .Select(t => t.OSThreadId.ToString())));
        }
예제 #4
0
        public BlockingObjectInformation(ClrDump clrDump, BlockingObject blockingObject)
        {
            ClrDump        = clrDump;
            BlockingObject = blockingObject;

            OwnersId = blockingObject.HasSingleOwner && blockingObject.Owner != null
                ? new HashSet <int>
            {
                blockingObject.Owner.ManagedThreadId
            }
                : new HashSet <int>(blockingObject.Owners.Where(thread => thread != null).Select(thread => thread.ManagedThreadId));
            WaitersId = blockingObject.Waiters != null
                ? new HashSet <int>(blockingObject.Waiters.Where(thread => thread != null).Select(thread => thread.ManagedThreadId))
                : new HashSet <int>();
        }
예제 #5
0
        public SDBlockingObject(BlockingObject obj)
        {
            foreach (ClrThread waiter in obj.Waiters?.Where(t => t != null) ?? new ClrThread[0])
            {
                this.WaiterOSThreadIds.Add(waiter.OSThreadId);
            }
            foreach (ClrThread owner in obj.Owners?.Where(t => t != null) ?? new ClrThread[0])
            {
                this.OwnerOSThreadIds.Add(owner.OSThreadId);
            }

            // convert reason to int, so it can be case to our UnifiedBlockingReason
            Reason               = (UnifiedBlockingReason)((int)obj.Reason);
            RecursionCount       = obj.RecursionCount;
            ManagedObjectAddress = obj.Object;
        }
예제 #6
0
파일: MixedStack.cs 프로젝트: tiandian/msos
        public UnifiedBlockingObject(BlockingObject obj)
            : this(BlockingObjectOrigin.ClrMD)
        {
            foreach (var owner in obj.Owners?.Where(o => o != null) ?? new ClrThread[0])
            {
                OwnerOSThreadIds.Add(owner.OSThreadId);
            }
            foreach (var waiter in obj.Waiters?.Where(w => w != null) ?? new ClrThread[0])
            {
                WaiterOSThreadIds.Add(waiter.OSThreadId);
            }

            Reason               = (UnifiedBlockingReason)((int)obj.Reason);
            RecursionCount       = obj.RecursionCount;
            ManagedObjectAddress = obj.Object;

            Type = UnifiedBlockingType.ClrBlockingObject;
        }
예제 #7
0
        public static SDBlockingObject ToSDModel(this BlockingObject obj)
        {
            var model = new SDBlockingObject();

            foreach (ClrThread waiter in obj.Waiters?.Where(t => t != null) ?? new ClrThread[0])
            {
                model.WaiterOSThreadIds.Add(waiter.OSThreadId);
            }
            foreach (ClrThread owner in obj.Owners?.Where(t => t != null) ?? new ClrThread[0])
            {
                model.OwnerOSThreadIds.Add(owner.OSThreadId);
            }

            // convert reason to int, so it can be case to our UnifiedBlockingReason
            model.Reason               = (UnifiedBlockingReason)((int)obj.Reason);
            model.RecursionCount       = obj.RecursionCount;
            model.ManagedObjectAddress = obj.Object;
            return(model);
        }
예제 #8
0
 private bool canGoTrough(GameObject collidingWith)
 {
     if (collidingWith)
     {
         BlockingObject blockingObject = collidingWith.GetComponent <BlockingObject>();
         if (blockingObject)
         {
             return(blockingObject.CanBeTraversed);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true); // Is not colliding with anything
     }
 }
예제 #9
0
            public int Add(Object blockingObject, ReasonForBlocking reasonForBlocking)
            {
                if (_blockingObjects == null)
                {
                    _blockingObjects = new BlockingObject[InitialSize];
                }

                int count = _count;

                if (count == _blockingObjects.Length)
                {
                    int newSize = count + GrowBy;
                    if (newSize > MaxSize)
                    {
                        return(-1);
                    }
                    Array.Resize <BlockingObject>(ref _blockingObjects, newSize);
                }

                _blockingObjects[count] = new BlockingObject(blockingObject, reasonForBlocking);
                _count++;
                return(count);
            }
        public BlockingObjectInformation(ClrDump clrDump, BlockingObject blockingObject)
        {
            ClrDump        = clrDump;
            BlockingObject = blockingObject;

            if (blockingObject.HasSingleOwner && blockingObject.Owner != null)
            {
                OwnersId = new HashSet <int>();
                OwnersId.Add(blockingObject.Owner.ManagedThreadId);
            }
            else
            {
                OwnersId = new HashSet <int>(blockingObject.Owners.Where(thread => thread != null).Select(thread => thread.ManagedThreadId));
            }
            if (blockingObject.Waiters != null)
            {
                WaitersId = new HashSet <int>(blockingObject.Waiters.Where(thread => thread != null).Select(thread => thread.ManagedThreadId));
            }
            else
            {
                WaitersId = new HashSet <int>();
            }
        }
예제 #11
0
파일: Monitor.cs 프로젝트: nattress/corert
            public int Add(Object blockingObject, ReasonForBlocking reasonForBlocking)
            {
                if (_blockingObjects == null)
                    _blockingObjects = new BlockingObject[InitialSize];

                int count = _count;
                if (count == _blockingObjects.Length)
                {
                    int newSize = count + GrowBy;
                    if (newSize > MaxSize)
                        return -1;
                    Array.Resize<BlockingObject>(ref _blockingObjects, newSize);
                }

                _blockingObjects[count] = new BlockingObject(blockingObject, reasonForBlocking);
                _count++;
                return count;
            }
예제 #12
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="BlockingObjectAdapter" /> class.
 /// </summary>
 /// <param name="converter">The converter.</param>
 /// <param name="blockingObject">The blocking object.</param>
 /// <exception cref="ArgumentNullException">blockingObject</exception>
 /// <inheritdoc />
 public BlockingObjectAdapter(IConverter converter, BlockingObject blockingObject) : base(converter)
 {
     BlockingObject = blockingObject ?? throw new ArgumentNullException(nameof(blockingObject));
 }
예제 #13
0
파일: threads.cs 프로젝트: mwatts/clrmd
 internal void SetBlockingObjects(BlockingObject[] blobjs)
 {
     _blockingObjs = blobjs;
 }
예제 #14
0
 public void RemoveBlockingObject(BlockingObject blockingObject)
 {
     this.blockingObjects.Remove(blockingObject);
 }
예제 #15
0
 public void AddBlockingObject(BlockingObject blockingObject)
 {
     this.blockingObjects.Add(blockingObject);
 }