View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005169||The Dark Mod||Coding||public||05.03.2020 04:15||21.03.2020 17:43|
|Product Version||TDM 2.08|
|Target Version||TDM 2.09|
|Summary||0005169: Clean multithreading routines|
|Description||The current set of multithreading routines are a mess for many reasons:|
1) A crazy mix of C++11 threads and Sys_XXX threads (the later ones rely on WinAPI/pthreads depending on platform). In some cases it is very hard to clarify how it works, e.g. I don't know whyWaitForSingleObject breaks std::condition_variable waits. Perhaps better to switch to Sys_XXX threads everywhere? Occasional ports from BFG codebase will introduce these functions anyway, so switching to C++11 is hardly possible.
2) Thread an synchronization objects live in weird places. For instance, the old Async threads live in Sys/Posix, while frontend threads live in ordinary engine code. Some functions uses Sys_Mutex (which are object-based and can be created in any number), while others rely on 4 numbered Sys_CriticalSection-s. I had a feeling that with more multithreading it's better to drop critical section API, but not sure here.
3) Thread termination is a problem. Old threads were terminated using pthread_cancel on Linux, new ones are terminated with separate bool flags. Both ways seem ugly. Also quick_exit was added recently.
|Tags||No tags attached.|