Search Unity

EntityCommandBuffer.PlayBack didn't wait other job complete?

Discussion in 'Entity Component System' started by wuyin1985, Jun 23, 2019.

  1. wuyin1985

    wuyin1985

    Joined:
    Sep 20, 2017
    Posts:
    3
    I have seen EntityCommandBuffer.PlayBack source code, when it playback command like AddEntity, It didn't CALL CompleteAllJobs like other EntityManager's API. So seem it didn't guarantee determinate ? Is it a bug or feature, or i have misunderstand something?
     
  2. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    You should just complete the jobs that are relevant to that ECB. Why would you complete ALL jobs?
     
  3. wuyin1985

    wuyin1985

    Joined:
    Sep 20, 2017
    Posts:
    3
    Because other job may excuting quering or operation on the same entity type which ECB add
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    That shouldn't be an issue.

    Are you using
    EntityCommandBufferSystem.AddJobHandleForProducer?
     
  5. wuyin1985

    wuyin1985

    Joined:
    Sep 20, 2017
    Posts:
    3
    So if a ECB is going to add a entity, the jobs run before the ECB must AddJobHandleForProducer to this ECB?
     
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Code (CSharp):
    1.             handle = new InitializeObservationsJob
    2.                 {
    3.                     TeamToEntity = this.teamToEntityMap,
    4.                     EntityCommandBuffer = this.barrier.CreateCommandBuffer().ToConcurrent(),
    5.                 }
    6.                 .Schedule(this, handle);
    7.  
    8.             this.barrier.AddJobHandleForProducer(handle);
    Should look something like this