Why are there multiple multithreading frameworks? |
History and different OSes are the main reasons why there are multiple frameworks. Before C++ introduced the
<thread> library each of the major OSes created their own version of threads. POSIX was the thread library for Mac and Linux, and the Windows Desktop API thread support was for (obviously) Windows.
Win32 is now referred to as the Windows Desktop API, WinAPI for short. There are later frameworks designed to hide the messy details of working with Windows. MFC and .NET are two of the frameworks.
Boost was an attempt to make a common interface to all the OSes before the C++ Standards Committee added direct thread support in C++11 by stealing shamelessly Boost's implementation and then peed on it to make it ISO C++. If you are dealing with code that is pre-C++11, you'd probably use the Boost variant. Especially if you wanted cross-platform for the code.
Same goes for POSIX threads, use the POSIX or Boost framework when dealing with pre-C++11 code.
Now, WinAPI/MFC code is a different story, IMO. The WinAPI is C-based, MFC is a wrapper around the WinAPI. Sometimes a very thin wrapper. While you can use C++11's thread library instead of the native support in WinAPI/MFC it can and likely will bloat up the size of the resulting executable, and potentially be a
minor bottleneck in thread processing. The native thread support is optimized to work well in conjunction with the rest of the WinAPI.
From time to time when working with WinAPI Desktop code I've used C++ features instead of WinAPI features, std::string vs. the various Windows data types for strings, and consistently the size of the final .exe is larger when using C++ strings.
https://learn.microsoft.com/en-us/windows/win32/intl/windows-data-types-for-strings
I am not a professional programmer, I am a self-taught for almost 3 decades programming hobbyist, and someone who deals only with C++ console and WinAPI GUI apps. What the benefits/deficits of using C++ thread support on Linux or MacOS vs. the POSIX thread support I don't have a clue.
So, with all that said the answer to "Are there legitimate reasons for using one thread framework over another?" is a definitive
IT DEPENDS.
If'n I'm mashing on WinAPI code, Desktop or MFC, new or older code, I'd use the thread support built-into the respective framework.
If'n I'm doing strict C++ console coding from scratch I'd use the C++ thread support. If'n I'm working with older code using Boost threading I'd retain that until I have an overwhelming need to modernize the code.