For handling the common idiom of a zero timeout.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
#include <chrono>
#include <iostream>
#include <string>
+#include <optional>
#include <sys/time.h>
#include "include/ceph_assert.h"
return std::chrono::duration_cast<timespan>(
std::chrono::duration<double>(d));
}
+ inline std::optional<timespan> maybe_timespan(const double d) {
+ return d ? std::make_optional(make_timespan(d)) : std::nullopt;
+ }
}
std::ostream& operator<<(std::ostream& m, const timespan& t);