Skip to content

Commit

Permalink
Merge pull request #54 from jogerh/indentation
Browse files Browse the repository at this point in the history
Harmonize line breaks for lambdas
  • Loading branch information
Jøger Hansegård authored Apr 11, 2023
2 parents 303402f + 03713fe commit 945655c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
3 changes: 1 addition & 2 deletions AtlServer/AtlHen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ HRESULT FreeThreadedHen::CluckAsync(IAsyncCluckObserver* cluckObserver)
winrt::com_ptr<IAsyncCluckObserver> observer;
observer.copy_from(cluckObserver);

auto result = std::async(std::launch::async, [observer]
{
auto result = std::async(std::launch::async, [observer] {
ComRuntime comRuntime{ Apartment::MultiThreaded };
return observer->OnCluck();
});
Expand Down
15 changes: 5 additions & 10 deletions ComUtility/ComApartment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class ApartmentContext
ComCallData data;
data.pUserDefined = &callable;
return m_context->ContextCallback(
[](ComCallData* data)
{
[](ComCallData* data) {
auto& callable = *static_cast<Callable*>(data->pUserDefined);
return callable();
}, &data, IID_ICallbackWithNoReentrancyToApplicationSTA, 5, nullptr);
Expand All @@ -49,8 +48,7 @@ class ApartmentContext
* all have been released. */
HRESULT Disconnect()
{
return Invoke([]
{
return Invoke([] {
return CoDisconnectContext(INFINITE);
});
}
Expand Down Expand Up @@ -83,8 +81,7 @@ ComApartment::ComApartment()
, m_apartmentInitialized{CreateNonSignaledManualResetEvent()}
, m_apartmentIsClosed{CreateNonSignaledManualResetEvent()}
{
m_thread = std::thread([this]
{
m_thread = std::thread([this] {
SetThreadDescription(GetCurrentThread(), L"ComApartment"); // Debugging help
RunMessagePump();
});
Expand All @@ -95,8 +92,7 @@ ComApartment::ComApartment()

// Initialize COM and the apartment context on the apartment
// thread and throw if it fails.
HR(InvokeOnApartment([this]
{
HR(InvokeOnApartment([this] {
const auto result = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
m_context = std::make_unique<ApartmentContext>();
return result;
Expand Down Expand Up @@ -142,8 +138,7 @@ std::future<HRESULT> ComApartment::InvokeOnApartment(std::function<HRESULT()> ca

ComApartment::~ComApartment()
{
const auto result = InvokeOnApartment([this]
{
const auto result = InvokeOnApartment([this] {
// We are shutting down the apartment, but to make sure CoUninitialize
// can complete, we need to disconnect any remaining proxies to ensure
// that we do not end up waiting on callbacks to client.
Expand Down
3 changes: 1 addition & 2 deletions TutorialsAndTests/Tests/AtlFreeServerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ TEST(AtlFreServerTests, RequireThat_CoCreateInstance_CreatesGuardDog_WhenCalledW
TEST(AtlFreServerTests, RequireThat_Bite_CausesDogToBitePostman)
{
const auto postman = wrl::Make<IPostmanMock>();
EXPECT_CALL(*postman.Get(), OnBitten()).WillOnce(Invoke([]()
{
EXPECT_CALL(*postman.Get(), OnBitten()).WillOnce(Invoke([] {
return S_OK;
}));

Expand Down
9 changes: 4 additions & 5 deletions TutorialsAndTests/Tests/AtlHenTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ TEST(AtlHenTests, RequireThat_Cluck_IsExecutedOnMainThread_WhenCalledFromWorkerT
// After all, it was created on a single threaded apartment (STA), and it should not be
// allowed to call it from any other thread.
auto observer = make_self<IAsyncCluckObserverMock>();
EXPECT_CALL(*observer, OnCluck()).WillOnce(Invoke([mainThreadId]
{
EXPECT_EQ(GetCurrentThreadId(), mainThreadId);
return S_OK; // Feel free to put a breakpoint here, and see which thread we are called on
}));
EXPECT_CALL(*observer, OnCluck()).WillOnce(Invoke([mainThreadId] {
EXPECT_EQ(GetCurrentThreadId(), mainThreadId);
return S_OK; // Feel free to put a breakpoint here, and see which thread we are called on
}));

ComPtr<IHen> hen;
HR(CoCreateInstance(CLSID_AtlHen, nullptr, CLSCTX_INPROC_SERVER, IID_IHen, &hen));
Expand Down

0 comments on commit 945655c

Please sign in to comment.