Search Unity

Function pointer ref-of-class-fields safety

Discussion in 'Burst' started by Zuntatos, Jun 2, 2021.

  1. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    If I call a burst method "void add (ref float3 a, ref float3 b)" like "add(ref someclass.varA, ref someother.varB)", is that potentially unsafe? What if a GC occurs (from another thread allocating or such) while the burst function is called? Does it pin the object, or does it use a temp copy, or some other way?
     
  2. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    417
    Yes, it should be safe as the .NET runtime is making sure that these refs are "fixed"
     
    Zuntatos and jasonboukheir like this.