forked from Kistler-Group/sdbus-cpp
Play with sync call data
This commit is contained in:
@ -149,13 +149,13 @@ MethodReply Proxy::callMethodWithAsyncReplyBlocking(const MethodCall& message, u
|
|||||||
|
|
||||||
// VARIANT 3: USING CLASSIC ASYNC APPROACH
|
// VARIANT 3: USING CLASSIC ASYNC APPROACH
|
||||||
// TODO: Try with thread local std::function
|
// TODO: Try with thread local std::function
|
||||||
// thread_local async_reply_handler asyncReplyCallback = [](MethodReply& reply, const Error* error)
|
// /*thread_local*/ SyncCallReplyData syncCallReplyData;
|
||||||
// {
|
|
||||||
// auto& syncCallReplyData = getSyncCallReplyData();
|
|
||||||
|
|
||||||
|
// async_reply_handler asyncReplyCallback = [&syncCallReplyData](MethodReply& reply, const Error* error)
|
||||||
|
// {
|
||||||
// std::unique_lock<std::mutex> lock(syncCallReplyData.mutex);
|
// std::unique_lock<std::mutex> lock(syncCallReplyData.mutex);
|
||||||
|
|
||||||
// syncCallReplyData.error = nullptr;
|
// //syncCallReplyData.error = nullptr;
|
||||||
// if (error == nullptr)
|
// if (error == nullptr)
|
||||||
// syncCallReplyData.reply = std::move(reply);
|
// syncCallReplyData.reply = std::move(reply);
|
||||||
// else
|
// else
|
||||||
@ -166,14 +166,13 @@ MethodReply Proxy::callMethodWithAsyncReplyBlocking(const MethodCall& message, u
|
|||||||
// syncCallReplyData.cond.notify_one();
|
// syncCallReplyData.cond.notify_one();
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// AsyncCalls::CallData callData{*this, /*std::move(*/asyncReplyCallback/*)*/, {}};
|
// AsyncCalls::CallData callData{*this, std::move(asyncReplyCallback), {}};
|
||||||
// message.sendWithAsyncReply((void*)&Proxy::sdbus_async_reply_handler, &callData, timeout);
|
// message.sendWithAsyncReply((void*)&Proxy::sdbus_async_reply_handler, &callData, timeout);
|
||||||
|
|
||||||
// auto& syncCallReplyData = getSyncCallReplyData();
|
|
||||||
// std::unique_lock<std::mutex> lock(syncCallReplyData.mutex);
|
// std::unique_lock<std::mutex> lock(syncCallReplyData.mutex);
|
||||||
// syncCallReplyData.cond.wait(lock, [&syncCallReplyData](){ return syncCallReplyData.arrived; });
|
// syncCallReplyData.cond.wait(lock, [&syncCallReplyData](){ return syncCallReplyData.arrived; });
|
||||||
|
|
||||||
// syncCallReplyData.arrived = false;
|
// //syncCallReplyData.arrived = false;
|
||||||
// if (syncCallReplyData.error)
|
// if (syncCallReplyData.error)
|
||||||
// throw *syncCallReplyData.error;
|
// throw *syncCallReplyData.error;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ namespace internal {
|
|||||||
{
|
{
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::condition_variable cond;
|
std::condition_variable cond;
|
||||||
bool arrived;
|
bool arrived{};
|
||||||
MethodReply reply;
|
MethodReply reply;
|
||||||
std::unique_ptr<Error> error;
|
std::unique_ptr<Error> error;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user