Exemplo n.º 1
0
        private void PinArray(object value, int size)
        {
            var pinsTemp = this.pins;

            if (this.pinsEnd <= pinsTemp)
            {
#if PROJECTN
                throw new IndexOutOfRangeException(SR.GetResourceString("EventSource_PinArrayOutOfRange", null));
#else
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_PinArrayOutOfRange"));
#endif
            }

            var datasTemp = this.datas;
            if (this.datasEnd <= datasTemp)
            {
#if PROJECTN
                throw new IndexOutOfRangeException(SR.GetResourceString("EventSource_DataDescriptorsOutOfRange", null));
#else
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
#endif
            }

            this.pins  = pinsTemp + 1;
            this.datas = datasTemp + 1;

            *pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
            datasTemp->m_Ptr  = (long)(ulong)(UIntPtr)(void *)pinsTemp->AddrOfPinnedObject();
            datasTemp->m_Size = size;
        }
Exemplo n.º 2
0
        unsafe public static T GetObject <T>(IntPtr ptr) where T : class
        {
            uv_req_t *req      = (uv_req_t *)ptr.ToPointer();
            GCHandle *gchandle = (GCHandle *)req->data;

            return(gchandle->Target as T);
        }
Exemplo n.º 3
0
 internal unsafe void Enable(byte *scratch, int scratchSize, EventSource.EventData *datas, int dataCount, GCHandle *pins, int pinCount)
 {
     this.datasStart     = datas;
     this.scratchEnd     = scratch + scratchSize;
     this.datasEnd       = datas + dataCount;
     this.pinsEnd        = pins + pinCount;
     this.scratch        = scratch;
     this.datas          = datas;
     this.pins           = pins;
     this.writingScalars = false;
 }
Exemplo n.º 4
0
        private unsafe void WriteCleanup(GCHandle *pPins, int cPins)
        {
            DataCollector.ThreadInstance.Disable();

            for (int i = 0; i < cPins; i++)
            {
                if (pPins[i].IsAllocated)
                {
                    pPins[i].Free();
                }
            }
        }
Exemplo n.º 5
0
        private unsafe void WriteCleanup(GCHandle *pPins, int cPins)
        {
            DataCollector.ThreadInstance.Disable();

            for (int i = 0; i != cPins; i++)
            {
                if (IntPtr.Zero != (IntPtr)pPins[i])
                {
                    pPins[i].Free();
                }
            }
        }
Exemplo n.º 6
0
 internal void Enable(
     byte* scratch,
     int scratchSize,
     EventSource.EventData* datas,
     int dataCount,
     GCHandle* pins,
     int pinCount)
 {
     this.datasStart = datas;
     this.scratchEnd = scratch + scratchSize;
     this.datasEnd = datas + dataCount;
     this.pinsEnd = pins + pinCount;
     this.scratch = scratch;
     this.datas = datas;
     this.pins = pins;
     this.writingScalars = false;
 }
Exemplo n.º 7
0
        private unsafe void PinArray(object value, int size)
        {
            GCHandle *gcHandlePtr = this.pins;

            if (this.pinsEnd <= gcHandlePtr)
            {
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_PinArrayOutOfRange"));
            }
            EventSource.EventData *eventDataPtr = this.datas;
            if (this.datasEnd <= eventDataPtr)
            {
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
            }
            this.pins  = gcHandlePtr + 1;
            this.datas = eventDataPtr + 1;
            *gcHandlePtr = GCHandle.Alloc(value, GCHandleType.Pinned);
            eventDataPtr->m_Ptr  = (long)(ulong)(UIntPtr)(void *)gcHandlePtr->AddrOfPinnedObject();
            eventDataPtr->m_Size = size;
        }
Exemplo n.º 8
0
        // Token: 0x060034D0 RID: 13520 RVA: 0x000CD718 File Offset: 0x000CB918
        private unsafe void PinArray(object value, int size)
        {
            GCHandle *ptr = this.pins;

            if (this.pinsEnd == ptr)
            {
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_PinArrayOutOfRange"));
            }
            EventSource.EventData *ptr2 = this.datas;
            if (this.datasEnd == ptr2)
            {
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
            }
            this.pins  = ptr + 1;
            this.datas = ptr2 + 1;
            *ptr = GCHandle.Alloc(value, GCHandleType.Pinned);
            ptr2->DataPointer = ptr->AddrOfPinnedObject();
            ptr2->m_Size      = size;
        }
Exemplo n.º 9
0
        private void PinArray(object? value, int size)
        {
            var pinsTemp = this.pins;
            if (this.pinsEnd <= pinsTemp)
            {
                throw new IndexOutOfRangeException(SR.EventSource_PinArrayOutOfRange);
            }

            var datasTemp = this.datas;
            if (this.datasEnd <= datasTemp)
            {
                throw new IndexOutOfRangeException(SR.EventSource_DataDescriptorsOutOfRange);
            }

            this.pins = pinsTemp + 1;
            this.datas = datasTemp + 1;

            *pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
            datasTemp->DataPointer = pinsTemp->AddrOfPinnedObject();
            datasTemp->m_Size = size;
        }
Exemplo n.º 10
0
        private void PinArray(object value, int size)
        {
            var pinsTemp = pins;

            if (pinsEnd <= pinsTemp)
            {
                throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_PinArrayOutOfRange"));
            }

            var datasTemp = datas;

            if (datasEnd <= datasTemp)
            {
                throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
            }

            pins  = pinsTemp + 1;
            datas = datasTemp + 1;

            *pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
            datasTemp->m_Ptr  = (long)(ulong)(UIntPtr)(void *)pinsTemp->AddrOfPinnedObject();
            datasTemp->m_Size = size;
        }
		private void* PinObject(object obj)
		{
			if(pinHandleInUseCount == pinHandleMaxCount)
			{
				int newCount = pinHandleMaxCount + 32;
				GCHandle* pNew = (GCHandle*)JniMem.Alloc(sizeof(GCHandle) * newCount);
				for(int i = 0; i < pinHandleMaxCount; i++)
				{
					pNew[i] = pinHandles[i];
				}
				for(int i = pinHandleMaxCount; i < newCount; i++)
				{
					pNew[i] = new GCHandle();
				}
				JniMem.Free((IntPtr)pinHandles);
				pinHandles = pNew;
				pinHandleMaxCount = newCount;
			}
			int index = pinHandleInUseCount++;
			if(!pinHandles[index].IsAllocated)
			{
				pinHandles[index] = GCHandle.Alloc(null, GCHandleType.Pinned);
			}
			pinHandles[index].Target = obj;
			return (void*)pinHandles[index].AddrOfPinnedObject();
		}
Exemplo n.º 12
0
        private void PinArray(object value, int size)
        {
            var pinsTemp = this.pins;
            if (this.pinsEnd <= pinsTemp)
            {
#if PROJECTN
                throw new IndexOutOfRangeException(SR.GetResourceString("EventSource_PinArrayOutOfRange", null));
#else
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_PinArrayOutOfRange"));
#endif
            }

            var datasTemp = this.datas;
            if (this.datasEnd <= datasTemp)
            {
#if PROJECTN
                throw new IndexOutOfRangeException(SR.GetResourceString("EventSource_DataDescriptorsOutOfRange", null));
#else
                throw new IndexOutOfRangeException(Environment.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
#endif
            }

            this.pins = pinsTemp + 1;
            this.datas = datasTemp + 1;

            *pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
            datasTemp->m_Ptr = (long)(ulong)(UIntPtr)(void*)pinsTemp->AddrOfPinnedObject();
            datasTemp->m_Size = size;
        }