Beispiel #1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        waitingEntities.Clear();
        var fetchJob = new FetchRequest
        {
            waitingEntities = waitingEntities,
            requests        = requesters.requestDatas,
            entities        = requesters.entities,
            counter         = counter
        };
        var fetchFence = fetchJob.Schedule(requesters.Length, SimulationState.TinyBatchSize, inputDeps);

        var fillFence = fetchFence;

        for (var i = 0; i < MAX_QUERIES; ++i)
        {
            var fillJob = new FillQuery
            {
                batch           = batches[i],
                waitingEntities = waitingEntities,
                requests        = requestDatas,
                counter         = counter,
                ID = i
            };
            fillFence = fillJob.Schedule(fillFence);
        }
        var fences = new NativeArray <JobHandle>(MAX_QUERIES, Allocator.Temp);

        for (var i = 0; i < MAX_QUERIES; ++i)
        {
            var processJob = new ProcessRequest {
                batch = batches[i]
            };
            fences[i] = processJob.Schedule(fillFence);
        }
        var processFence = JobHandle.CombineDependencies(fences);
        var getFence     = processFence;

        for (var i = 0; i < MAX_QUERIES; ++i)
        {
            var getJob = new GetResult
            {
                batch    = batches[i],
                paths    = paths,
                requests = requestDatas,
                counter  = counter
            };
            getFence = getJob.Schedule(getFence);
        }

        for (var i = 0; i < MAX_QUERIES; ++i)
        {
            var clearResultJob = new ClearResult
            {
                batch = batches[i]
            };
            fences[i] = clearResultJob.Schedule(getFence);
        }
        endFence = JobHandle.CombineDependencies(fences);

        fences.Dispose();

        return(endFence);
    }