Replaced POSIX threads under Windows with stdlib implementations since it is under LGPL license#100
Conversation
…library but sadly under LGPL so we cannot link it statically. Since C++ 11 there are official implementations std::mutex, std::thread and std::conditional_variable. So I put those in which gets rid of POSIX threads under Windows which resolves our licensing issue. There is a define OX_CPP11THREADS that needs to be set in order to enable the use of the stdlib classes.
|
I had to split the mutex class into Mutex and MutexRecursive since the recursive mutex in stdlib is its own type. |
|
I noticed that. The ThreadDispatcher is probably still a bit fishy. When you look at the file you see in line 156, that I put in a todo. The problem is that POSIX allows you to have a condition for a recursive mutex. The stdlib does not support this. There is a type conditional_variable_any that would take a recursive mutex, but the documentation explicitly says that this will not work. So I would see two solutions here. Either use two mutex, one for locking one only to wait for the condition, or we use like an atomic int to establish a communication. My current workaround looks like this which isprobably not safe. Do you have a unit test or something that could be used to very if no problem exists? Even just some instructions on how to test this would be fine. Cheers, |
…-framework into holoeye_cpp11threads
|
I went with the following solution in the end: ` std::recursive_mutex _mutex; |
The oxygine engine uses POSIX threads under Windows which is a handy library but sadly under LGPL so we cannot link it statically. Since C++ 11 there are official implementations std::mutex, std::thread and std::conditional_variable. So I put those in which gets rid of POSIX threads under Windows which resolves our licensing issue. There is a define OX_CPP11THREADS that needs to be set in order to enable the use of the stdlib classes.