forked from Kistler-Group/sdbus-cpp
fix timeout handling * Despite what is documented in sd_bus_get_timeout(3), the timeout returned is actually an absolute time point of Linux's CLOCK_MONOTONIC clock. Hence, we first have to subtract the current time from the timeout in order to get a relative time that can be passed to poll. * For async call timeouts to reliably work, we need a way to notify the event loop of a connection that is currently blocked waiting in poll. I.e. assume the event loop thread entered poll with a timeout set to T1. Afterwards, the main thread starts an async call C with a timeout T2 < T1. In order for C to be canceled after its timeout T1 has elapsed, we have to be able to notify the event loop so that it can update its poll data. Co-authored-by: Urs Ritzmann <ursritzmann@protonmail.ch> Co-authored-by: Lukasz Marcul <lukasz.marcul@onemeter.com>
This commit is contained in:
co-authored by
Urs Ritzmann
Lukasz Marcul
parent
0b8f2d9752
commit
bb0f3f0242
@@ -97,11 +97,11 @@ void TestProxy::installDoOperationClientSideAsyncReplyHandler(std::function<void
|
||||
m_DoOperationClientSideAsyncReplyHandler = std::move(handler);
|
||||
}
|
||||
|
||||
uint32_t TestProxy::doOperationWith500msTimeout(uint32_t param)
|
||||
uint32_t TestProxy::doOperationWithTimeout(const std::chrono::microseconds &timeout, uint32_t param)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
uint32_t result;
|
||||
getProxy().callMethod("doOperation").onInterface(sdbus::test::INTERFACE_NAME).withTimeout(500000us).withArguments(param).storeResultsTo(result);
|
||||
getProxy().callMethod("doOperation").onInterface(sdbus::test::INTERFACE_NAME).withTimeout(timeout).withArguments(param).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -126,12 +126,12 @@ void TestProxy::doErroneousOperationClientSideAsync()
|
||||
});
|
||||
}
|
||||
|
||||
void TestProxy::doOperationClientSideAsyncWith500msTimeout(uint32_t param)
|
||||
void TestProxy::doOperationClientSideAsyncWithTimeout(const std::chrono::microseconds &timeout, uint32_t param)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
getProxy().callMethodAsync("doOperation")
|
||||
.onInterface(sdbus::test::INTERFACE_NAME)
|
||||
.withTimeout(500000us)
|
||||
.withTimeout(timeout)
|
||||
.withArguments(param)
|
||||
.uponReplyInvoke([this](const sdbus::Error* error, uint32_t returnValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user