Locks are used to make RTPacket.cs thread safe. In order to have one thread executing the SetData method while another thread could poll the parsed data through different Get methods. The design dependnds on the .ToList method for making shallow copies of the shared data. This is working right now because most components simply allocate new arrays for every packet. This creates garbage which is no good for realtime applications.
We could conserve allocations by reusing lists instead of depending on fresh arrays. We would also need to make deep copies of the structures instead of using .ToList in the Get methods.
Locks are used to make RTPacket.cs thread safe. In order to have one thread executing the SetData method while another thread could poll the parsed data through different Get methods. The design dependnds on the .ToList method for making shallow copies of the shared data. This is working right now because most components simply allocate new arrays for every packet. This creates garbage which is no good for realtime applications.
We could conserve allocations by reusing lists instead of depending on fresh arrays. We would also need to make deep copies of the structures instead of using .ToList in the Get methods.