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
@@ -28,6 +28,8 @@
|
||||
#define SDBUS_CPP_INTEGRATIONTESTS_DEFS_H_
|
||||
|
||||
#include "sdbus-c++/Types.h"
|
||||
#include <chrono>
|
||||
#include <ostream>
|
||||
|
||||
namespace sdbus { namespace test {
|
||||
|
||||
@@ -54,6 +56,20 @@ const bool DEFAULT_BLOCKING_VALUE{true};
|
||||
|
||||
constexpr const double DOUBLE_VALUE{3.24L};
|
||||
|
||||
/** Duration stream operator for human readable gtest value output.
|
||||
*
|
||||
* Note that the conversion to double is lossy if the input type has 64 or more bits.
|
||||
* This is ok for our integration tests because they don't have very
|
||||
* accurate timing requirements.
|
||||
*
|
||||
* @return human readable duration in seconds
|
||||
*/
|
||||
template< class Rep, class Period >
|
||||
static std::ostream& operator<<(std::ostream& os, const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(d);
|
||||
return os << seconds.count() << " s";
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDBUS_CPP_INTEGRATIONTESTS_DEFS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user