Пример #1
0
            public unsafe UnLoadJob(Allocator alloc)
            {
                _target = new NativeList <UnLoadJobTarget <Tdata> >(alloc);
                _info   = new PtrHandle <UnLoadJobInfo>(alloc);

                _info.Target->job_state = ReadJobState.Completed;
            }
Пример #2
0
            public ParseJob(Allocator alloc, bool enableBurst = true)
            {
                _byteReader = new AsyncByteReader(alloc);
                _worker     = new ParseLinesWorker(alloc);

                _lines = new NativeStringList(alloc);

                _data      = new GCHandle <Tdata>();
                _state_ptr = new PtrHandle <ReadStateImpl>();  // do not allocate (this will be assigned). used as reference.

                _info = new PtrHandle <ParseJobInfo>(alloc);

                _info.Target->decodeBlockSize = Define.DefaultDecodeBlock;
                _info.Target->blockNum        = 0;
                _info.Target->blockPos        = 0;

                _info.Target->allocated     = true;
                _info.Target->disposeHandle = false;
                _info.Target->enableBurst   = enableBurst;

                _info.Target->jobHandle = new JobHandle();

                _timer         = new GCHandle <System.Diagnostics.Stopwatch>();
                _timer_ms_coef = 1.0f;
            }
Пример #3
0
        public unsafe ParseLinesWorker(Allocator alloc)
        {
            _charBuff     = new NativeHeadRemovableList <Char16>(alloc);
            _continueBuff = new NativeList <Char16>(alloc);

            _preamble = new NativeList <byte>(alloc);
            _info     = new PtrHandle <Info>(alloc);
        }
        public unsafe NativeJaggedArray(int bufferCapacity, int indexCapacity, Allocator alloc)
        {
            _buff          = new NativeList <T>(bufferCapacity, alloc);
            _elemIndexList = new NativeList <ElemIndex>(indexCapacity, alloc);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            genTrace     = new NativeArray <long>(1, alloc);
            genSignature = new PtrHandle <long>((long)_buff.GetUnsafePtr(), alloc);  // sigunature = address value of ptr for char_arr.
#endif
        }
        public unsafe void AddFile(string str)
        {
            _pathList.Add(str);

            _data.Add(new T());
            _data[_data.Count - 1].Init();

            var s_tmp = new PtrHandle <ReadStateImpl>(_alloc);

            s_tmp.Target->Clear();
            _state.Add(s_tmp);
        }
        /// <summary>
        /// the constructor must be called by main thread only.
        /// </summary>
        /// <param name="path"></param>
        public AsyncByteReader(Allocator alloc)
        {
            _byteBuffer = new NativeList <byte>(Define.MinByteBufferSize, alloc);
            _info       = new PtrHandle <AsyncByteReaderInfo>(alloc);

            _readCmd = new PtrHandle <ReadCommand>(alloc);

            _info.Target->bufferSize = Define.MinByteBufferSize;
            _info.Target->dataSize   = 0;

            _info.Target->allocated = true;
        }
        private unsafe void Init(string path, Allocator alloc, Encoding encoding)
        {
            Data = new T();
            Data.Init();

            Path       = path;
            _blockSize = Define.DefaultDecodeBlock;
            Encoding   = encoding;

            _parser = new ParseJob <T>(alloc);
            _state  = new PtrHandle <ReadStateImpl>(alloc);
            _state.Target->Clear();

            _allocated = true;
        }
Пример #8
0
            private void InitializeReadJob(Encoding encoding, Tdata data, PtrHandle <ReadStateImpl> state_ptr)
            {
                this.DisposeHandle();

                _decoder.Create(encoding.GetDecoder());
                _worker.SetPreamble(encoding.GetPreamble());

                _data.Create(data);
                _state_ptr = state_ptr;
                _state_ptr.Target->JobState       = ReadJobState.ReadAsync;
                _state_ptr.Target->DelayReadAsync = -1;
                _state_ptr.Target->DelayParseText = -1;
                _state_ptr.Target->DelayPostProc  = -1;

                _info.Target->disposeHandle = true;

                _timer.Create(new System.Diagnostics.Stopwatch());
                _timer.Target.Start();
                _timer_ms_coef = 1000.0f / System.Diagnostics.Stopwatch.Frequency;
            }
Пример #9
0
        /// <summary>
        /// the constructor must be called by main thread only.
        /// </summary>
        /// <param name="path"></param>
        public NativeByteStreamReader(Allocator alloc)
        {
            _info         = new PtrHandle <ByteStreamReaderInfo>(alloc);
            _byteBuffer   = new NativeArray <byte>(Define.MinBufferSize, alloc);
            _readCommands = new NativeArray <ReadCommand>(1, alloc);

            _path.Create("");
            _info.Target->disposePathHandle = true;

            _info.Target->fileSize = 0;

            _alloc = alloc;

            _info.Target->dataLength = 0;

            _info.Target->blockSize = 0;
            _info.Target->blockNum  = 0;
            _info.Target->blockPos  = 0;

            _info.Target->allocated = true;
        }
Пример #10
0
 public unsafe NativeHeadRemovableList(int size, Allocator alloc)
 {
     _list  = new NativeList <T>(size, alloc);
     _start = new PtrHandle <int>(alloc);
 }
Пример #11
0
 public unsafe NativeHeadRemovableList(Allocator alloc)
 {
     _list = new NativeList <T>(8, alloc);
     _list.Clear();
     _start = new PtrHandle <int>(alloc);
 }
Пример #12
0
            public void ReadFileInMainThread(string path, Encoding encoding, Tdata data, PtrHandle <ReadStateImpl> state_ptr)
            {
                this.InitializeReadJob(encoding, data, state_ptr);

                var job_byteReader = _byteReader.ReadFileAsync(path);

                job_byteReader.Complete();
                this.Run();
            }
Пример #13
0
            public JobHandle ReadFileAsync(string path, Encoding encoding, Tdata data, PtrHandle <ReadStateImpl> state_ptr)
            {
                this.InitializeReadJob(encoding, data, state_ptr);

                var job_byteReader = _byteReader.ReadFileAsync(path);

                _info.Target->jobHandle = this.Schedule(job_byteReader);

                return(_info.Target->jobHandle);
            }
 public unsafe NativeBase64Encoder(Allocator alloc)
 {
     _info = new PtrHandle <Base64Info>(alloc);
     _info.Target->Clear();
     _info.Target->insertLF = true;
 }
 public unsafe NativeBase64Decoder(Allocator alloc)
 {
     _info = new PtrHandle <Base64Info>(alloc);
     _info.Target->Clear();
 }