Announcement

Collapse
No announcement yet.

Thread-unsafe libraries + std::mutex, or FRunnable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Thread-unsafe libraries + std::mutex, or FRunnable?

    I am trying to figure out the best way to use external C++ DLLs that are not threadsafe. In previous projects I've used a mutex to make sure that two threads don't collide when they call certain functions in the DLL classes. Basically I set up a static mutex that is accessed by several different functions.

    FCriticalSection looks like it won't work for me because it only protects a particular section of code. The problem with that I'm trying to lock all functions accessed from the DLL, which are accessed by several different functions.

    I'd like to take advantage of any prioritization and optimization built into UE4. As I see it, I have two workable choices:
    - Keep using std::mutex in the DLL, which may conflict with UE4 locking on occasion, and doesn't use any optimizations.
    - Make sure that all calls to the DLL functions occur from a single FRunnable.

    Any recommendations about which is preferable?
Working...
X