Skip to content

Commit

Permalink
Add flag to use SetThreadDescription on Windows
Browse files Browse the repository at this point in the history
SetThreadDescription is only available on Windows 10 and newer. On
Windows 7 an app using SetThreadDescription will crash on startup.
With this change threads on Windows will not be named by default and
LINK_WINDOWS_SETTHREADDESCRIPTION can explicitly be set for apps only
supporting Windows 10 and up.
  • Loading branch information
fgo-ableton committed Mar 30, 2022
1 parent d03361f commit 2641130
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,37 @@ environment:
CXX: g++-7
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Debug
GENERATOR: Visual Studio 14 2015 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 14 2015 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Wasapi
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 14 2015 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 15 2017 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: ON
CONFIGURATION: Release
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
AUDIO_DRIVER: Wasapi
THREAD_DESCRIPTION: ON
CONFIGURATION: Debug
GENERATOR: Visual Studio 17 2022
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
Expand Down Expand Up @@ -122,7 +129,7 @@ for:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
build_script:
- py -3 ci/configure.py --audio-driver %AUDIO_DRIVER% --generator "%GENERATOR%" --flags="-DCMAKE_SYSTEM_VERSION=10.0.18362.0"
- py -3 ci/configure.py --audio-driver %AUDIO_DRIVER% --thread-description %THREAD_DESCRIPTION% --generator "%GENERATOR%" --flags="-DCMAKE_SYSTEM_VERSION=10.0.18362.0"
- py -3 ci/build.py --configuration %CONFIGURATION%
test_script:
- py -3 ci/run-tests.py --target LinkCoreTest
Expand Down
6 changes: 6 additions & 0 deletions ci/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def parse_args():
'-f', '--flags',
help='Additional CMake flags')

arg_parser.add_argument(
'--thread-description',
help='Set thread description. (Windows only)')

return arg_parser.parse_args(sys.argv[1:])


Expand All @@ -60,6 +64,8 @@ def build_cmake_args(args):
cmake_args.append('-DLINK_BUILD_ASIO=ON')
else:
cmake_args.append('-DLINK_BUILD_ASIO=OFF')
if args.thread_description == 'ON':
cmake_args.append('-DLINK_WINDOWS_SETTHREADDESCRIPTION=ON')
elif 'linux' in sys.platform:
if args.audio_driver == 'Jack':
cmake_args.append('-DLINK_BUILD_JACK=ON')
Expand Down
3 changes: 3 additions & 0 deletions cmake_include/ConfigureCompileFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
else()
add_definitions("/DLINK_BUILD_VLD=0")
endif()
if(LINK_WINDOWS_SETTHREADDESCRIPTION)
add_definitions("/DLINK_WINDOWS_SETTHREADDESCRIPTION")
endif()

set(build_flags_DEBUG_LIST
"/DDEBUG=1"
Expand Down
4 changes: 2 additions & 2 deletions include/ableton/platforms/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <ableton/platforms/stl/Random.hpp>
#include <ableton/platforms/windows/Clock.hpp>
#include <ableton/platforms/windows/ScanIpIfAddrs.hpp>
#if _MSC_VER >= 1920
#if defined(LINK_WINDOWS_SETTHREADDESCRIPTION)
#include <ableton/platforms/windows/ThreadFactory.hpp>
#endif
#elif defined(LINK_PLATFORM_MACOSX)
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace platform
#if defined(LINK_PLATFORM_WINDOWS)
using Clock = platforms::windows::Clock;
using Random = platforms::stl::Random;
#if _MSC_VER >= 1920
#if defined(LINK_WINDOWS_SETTHREADDESCRIPTION)
using IoContext = platforms::asio::Context<platforms::windows::ScanIpIfAddrs,
util::NullLog,
platforms::windows::ThreadFactory>;
Expand Down

0 comments on commit 2641130

Please sign in to comment.