Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverse async in IPC send message #1358

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions WeaselIPC/WeaselClientImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "stdafx.h"
#include "WeaselClientImpl.h"
#include <StringAlgorithm.hpp>
#include <future>
#include <chrono>

using namespace weasel;

Expand Down Expand Up @@ -197,29 +195,7 @@ LRESULT ClientImpl::_SendMessage(WEASEL_IPC_COMMAND Msg,
DWORD lParam) {
try {
PipeMessage req{Msg, wParam, lParam};
LRESULT ret = 0;
switch (Msg) {
case WEASEL_IPC_PROCESS_KEY_EVENT: {
auto future = std::async(std::launch::async, [this, &req]() {
return channel.Transact(req);
});
// wait Transact complete or overtime
if (future.wait_for(std::chrono::seconds(2)) ==
std::future_status::timeout) {
// Transact overtime
ret = 0;
} else {
// Transact complete
ret = future.get();
}
break;
}
default: {
ret = channel.Transact(req);
break;
}
}
return ret;
return channel.Transact(req);
} catch (DWORD /* ex */) {
return 0;
}
Expand Down