LivoxGen1: Port to coros
No longer uses CPS. We also found and documented a potential bug in the way we deal with disablePcloudData during detachDeviceReq.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#ifndef ADAPTERS_BOOST_ASIO_DEADLINE_TIMER_AREQ_H
|
||||
#define ADAPTERS_BOOST_ASIO_DEADLINE_TIMER_AREQ_H
|
||||
|
||||
#include <boostAsioLinkageFix.h>
|
||||
#include <functional>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <adapters/smo/cpsCallbackAReq.h>
|
||||
|
||||
namespace adapters::boostAsio {
|
||||
|
||||
using TimerWaitCbFn = std::function<void(bool success)>;
|
||||
|
||||
inline auto deadlineTimerWaitAReq(
|
||||
boost::asio::io_service &ioService,
|
||||
const boost::posix_time::milliseconds delay)
|
||||
{
|
||||
return smo::cpsBoundary::CpsCallbackAReq<bool, TimerWaitCbFn, std::function<void(sscl::cps::Callback<TimerWaitCbFn>)>>(
|
||||
ioService,
|
||||
[&ioService, delay](sscl::cps::Callback<TimerWaitCbFn> cb)
|
||||
{
|
||||
auto timer = std::make_shared<boost::asio::deadline_timer>(ioService);
|
||||
timer->expires_from_now(delay);
|
||||
timer->async_wait(
|
||||
[timer, cb](const boost::system::error_code &error) mutable
|
||||
{
|
||||
cb.callbackFn(!error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace adapters::boostAsio
|
||||
|
||||
#endif // ADAPTERS_BOOST_ASIO_DEADLINE_TIMER_AREQ_H
|
||||
Reference in New Issue
Block a user