예제 #1
0
        public ref T ReserveEnqueue <T>(out UnsafeArrayIndex index) where T : struct
        {
            unsafe
            {
                BasicTests();

                var sizeOf = MemoryUtilities.SizeOf <T>();
                if (_queue->space - sizeOf < 0)
                {
                    //Todo: NativeBag is very complicated. At the time of writing of this comment I don't remember if the sizeof really needs to be aligned by 4. To check and change this comment
                    _queue->Realloc((uint)((_queue->capacity + MemoryUtilities.Align4((uint)sizeOf)) * 2.0f));
                }

#if ENABLE_THREAD_SAFE_CHECKS
                try
                {
#endif

                return(ref _queue->Reserve <T>(out index));

#if ENABLE_THREAD_SAFE_CHECKS
            }
            finally
            {
                Volatile.Write(ref _threadSentinel, 0);
            }
#endif
            }
        }
예제 #2
0
        public ref T ReserveEnqueue <T>(out UnsafeArrayIndex index) where T : struct
        {
            unsafe
            {
                BasicTests();

                var sizeOf = MemoryUtilities.SizeOf <T>();
                if (_queue->space - sizeOf < 0)
                {
                    _queue->Realloc((uint)((_queue->capacity + MemoryUtilities.Align4((uint)sizeOf)) * 2.0f));
                }

#if ENABLE_THREAD_SAFE_CHECKS
                try
                {
#endif

                return(ref _queue->Reserve <T>(out index));

#if ENABLE_THREAD_SAFE_CHECKS
            }
            finally
            {
                Volatile.Write(ref _threadSentinel, 0);
            }
#endif
            }
        }