wip
This commit is contained in:
parent
68294f863d
commit
2c947a0cd2
|
@ -15,8 +15,9 @@
|
|||
<!-- ========================= Headers ======================== -->
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="inc\ScopedResourceLoader.h" />
|
||||
<ClInclude Include="inc\LibraryResources.h" />
|
||||
<ClInclude Include="inc\ScopedResourceLoader.h" />
|
||||
<ClInclude Include="inc\thread_assert.h" />
|
||||
<ClInclude Include="inc\ThrottledFunc.h" />
|
||||
<ClInclude Include="inc\Utils.h" />
|
||||
<ClInclude Include="inc\WtExeUtils.h" />
|
||||
|
@ -28,6 +29,7 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="LibraryResources.cpp" />
|
||||
<ClCompile Include="ScopedResourceLoader.cpp" />
|
||||
<ClCompile Include="thread_assert.cpp" />
|
||||
</ItemGroup>
|
||||
<!-- ========================= idl Files ======================== -->
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="LibraryResources.cpp" />
|
||||
<ClCompile Include="ScopedResourceLoader.cpp" />
|
||||
<ClCompile Include="thread_assert.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="ScopedResourceLoader.h" />
|
||||
<ClInclude Include="inc\LibraryResources.h" />
|
||||
<ClInclude Include="inc\ScopedResourceLoader.h" />
|
||||
<ClInclude Include="inc\thread_assert.h" />
|
||||
<ClInclude Include="inc\ThrottledFunc.h" />
|
||||
<ClInclude Include="inc\Utils.h" />
|
||||
<ClInclude Include="inc\WtExeUtils.h" />
|
||||
|
|
14
src/cascadia/WinRTUtils/inc/thread_assert.h
Normal file
14
src/cascadia/WinRTUtils/inc/thread_assert.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef NDEBUG
|
||||
constexpr void mark_as_foreground_thread() {}
|
||||
constexpr void assert_foreground_thread() {}
|
||||
constexpr void assert_background_thread() {}
|
||||
#else
|
||||
void mark_as_foreground_thread();
|
||||
void assert_foreground_thread();
|
||||
void assert_background_thread();
|
||||
#endif
|
27
src/cascadia/WinRTUtils/thread_assert.cpp
Normal file
27
src/cascadia/WinRTUtils/thread_assert.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "thread_assert.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
static const DWORD foreground_thread_id = []() -> DWORD {
|
||||
const auto id = GetCurrentThreadId();
|
||||
OutputDebugStringW((std::wstring(L"#### ") + std::to_wstring(id) + L" ####").c_str());
|
||||
return id;
|
||||
}();
|
||||
|
||||
void assert_foreground_thread() {
|
||||
if (foreground_thread_id != GetCurrentThreadId()) {
|
||||
//throw std::exception("expected to be called from a foreground thread");
|
||||
}
|
||||
}
|
||||
|
||||
void assert_background_thread() {
|
||||
if (foreground_thread_id != GetCurrentThreadId()) {
|
||||
throw std::exception("expected to be called from a background thread");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NDEBUG
|
Loading…
Reference in a new issue