ryanpoulos / LabVIEW-Memory

A library that provides a set of VIs and classes for performing explicit memory operations, such as pointer allocation and deallocation, in LabVIEW.
MIT License
3 stars 3 forks source link

Memory manager is not thread safe #10

Open csjall opened 5 years ago

csjall commented 5 years ago

Currently there is no synchronization that prevents me from reading/writing/disposing a buffer at the same time from multiple threads. This could lead to race conditions where we crash or get corrupt data based on timing of the system. We should add some synchronization primitives to have atomic read/write/dispose methods.

ryanpoulos commented 5 years ago

Even though we discussed this in person, I'll reiterate what we decided here:

The current classes (Pointer, Pointer.Internal, and Pointer.External) are not thread safe on purpose, as I believe adding a mutex lock to every read/write would add unnecessary overhead for applications where thread safety is not a concern. I don't want to reduce performance just to cover a specific use case. With that said, I do believe it would be beneficial to add a new class called ProtectedPointer, or something like that, that does use a mutex internally to ensure thread safety.