Пример #1
0
 public HashSlot(string key, WeakReference value, SlotCounter counter)
 {
     this.Key         = key;
     this.Value       = value;
     this.CreatedDate = DateTime.Now;
     this.Counter     = counter;
 }
Пример #2
0
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
        {
            ObjectDataBuilder objData = new ObjectDataBuilder(factory, relocsOnly);

            objData.RequireInitialPointerAlignment();
            objData.AddSymbol(this);

            ComputeOptionalEETypeFields(factory, relocsOnly);

            OutputGCDesc(ref objData);
            OutputComponentSize(ref objData);
            OutputFlags(factory, ref objData);
            OutputBaseSize(ref objData);
            OutputRelatedType(factory, ref objData);

            // Number of vtable slots will be only known later. Reseve the bytes for it.
            var vtableSlotCountReservation = objData.ReserveShort();

            // Number of interfaces will only be known later. Reserve the bytes for it.
            var interfaceCountReservation = objData.ReserveShort();

            objData.EmitInt(_type.GetHashCode());
            objData.EmitPointerReloc(factory.TypeManagerIndirection);

            if (EmitVirtualSlotsAndInterfaces)
            {
                // Emit VTable
                Debug.Assert(objData.CountBytes - ((ISymbolDefinitionNode)this).Offset == GetVTableOffset(objData.TargetPointerSize));
                SlotCounter virtualSlotCounter = SlotCounter.BeginCounting(ref /* readonly */ objData);
                OutputVirtualSlots(factory, ref objData, _type, _type, relocsOnly);

                // Update slot count
                int numberOfVtableSlots = virtualSlotCounter.CountSlots(ref /* readonly */ objData);
                objData.EmitShort(vtableSlotCountReservation, checked ((short)numberOfVtableSlots));

                // Emit interface map
                SlotCounter interfaceSlotCounter = SlotCounter.BeginCounting(ref /* readonly */ objData);
                OutputInterfaceMap(factory, ref objData);

                // Update slot count
                int numberOfInterfaceSlots = interfaceSlotCounter.CountSlots(ref /* readonly */ objData);
                objData.EmitShort(interfaceCountReservation, checked ((short)numberOfInterfaceSlots));
            }
            else
            {
                // If we're not emitting any slots, the number of slots is zero.
                objData.EmitShort(vtableSlotCountReservation, 0);
                objData.EmitShort(interfaceCountReservation, 0);
            }

            OutputFinalizerMethod(factory, ref objData);
            OutputOptionalFields(factory, ref objData);
            OutputNullableTypeParameter(factory, ref objData);
            OutputGenericInstantiationDetails(factory, ref objData);

            return(objData.ToObjectData());
        }
Пример #3
0
        public void Should_calculate_current_slot_correct()
        {
            // Arrange
            var right = new Mock <IRight>();

            right.Setup(r => r.Now).Returns(new DateTime(2020, 1, 1));
            var sc = new SlotCounter(right.Object);

            // Act, Assert
            sc.CurrentSlot.ShouldBe(0);
        }
Пример #4
0
        public void Should_set_next_slot_time_correct()
        {
            // Arrange
            var right = new Mock <IRight>();

            right.Setup(r => r.Now).Returns(new DateTime(2020, 1, 1));
            var sc = new SlotCounter(right.Object);

            // Act
            sc.CalculateNextSlotStart();

            // Assert
            sc.NextSlotTimeStart.ShouldBe(new DateTime(2020, 1, 1).AddMinutes(6));
        }
Пример #5
0
 void Start()
 {
     player      = FindObjectOfType <Player> ().GetComponent <Player> ();
     slotCounter = FindObjectOfType <SlotCounter> ().GetComponent <SlotCounter> ();
     compile     = FindObjectOfType <Compile> ().GetComponent <Compile> ();
 }