本文整理汇总了C++中boost::asio::deadline_timer类的典型用法代码示例。如果您正苦于以下问题:C++ deadline_timer类的具体用法?C++ deadline_timer怎么用?C++ deadline_timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了deadline_timer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: set_timer
inline void set_timer(io::deadline_timer& timer, uint64_t milliseconds,
Handler&& handler) {
if (milliseconds != length_framed_connection::no_deadline) {
timer.expires_from_now(boost::posix_time::milliseconds(milliseconds));
timer.async_wait(std::forward<Handler>(handler));
}
}
开发者ID:reinfer,项目名称:riakpp,代码行数:7,代码来源:length_framed_connection.cpp
示例2: handle_timer
//---------------------------------------------------------
void handle_timer(boost::asio::deadline_timer& timer, const boost::system::error_code& ec)
{
std::cout<<"*"<<std::flush;
timer.expires_from_now(boost::posix_time::seconds(1)); ///!\ important /!\ got to be reset
timer.async_wait(boost::bind(handle_timer, boost::ref(timer), boost::asio::placeholders::error));
}
开发者ID:alexandry-augustin,项目名称:boost,代码行数:8,代码来源:boost_asio_timer.cpp
示例3: check_interrupt
static void check_interrupt( boost::asio::deadline_timer& c )
{
if( boost::this_thread::interruption_requested() )
throw std::runtime_error("Thread interrupted.");
c.expires_from_now( boost::posix_time::seconds(1) );
c.async_wait( boost::bind( &listener::check_interrupt, boost::ref(c) ) );
}
开发者ID:jadedrip,项目名称:lugce,代码行数:7,代码来源:listener.hpp
示例4: deadlineCallback
void deadlineCallback(boost::asio::deadline_timer& t, udp::socket& s)
{
if (t.expires_at() <= boost::asio::deadline_timer::traits_type::now())
{
s.cancel();
t.expires_at(boost::posix_time::pos_infin);
}
t.async_wait(boost::bind(&CompactRIOCommunicationNode::deadlineCallback, this, boost::ref(t), boost::ref(s)));
}
开发者ID:Lenskiy,项目名称:Unmanned-ground-vehicle,代码行数:9,代码来源:crio_comm_node.cpp
示例5: keepRunning
void PionScheduler::keepRunning(boost::asio::io_service& my_service,
boost::asio::deadline_timer& my_timer)
{
if (m_is_running) {
// schedule this again to make sure the service doesn't complete
my_timer.expires_from_now(boost::posix_time::seconds(KEEP_RUNNING_TIMER_SECONDS));
my_timer.async_wait(boost::bind(&PionScheduler::keepRunning, this,
boost::ref(my_service), boost::ref(my_timer)));
}
}
开发者ID:Beirdo,项目名称:pion,代码行数:10,代码来源:PionScheduler.cpp
示例6: HandleReceiveFrom
void Detection::HandleReceiveFrom(int packet_type, int tracker_index, boost::asio::deadline_timer& timer,
const boost::system::error_code& error, size_t bytes_recvd)
{
std::ofstream fout("text.txt", std::ofstream::ate|std::ofstream::app);
if (!error || error == boost::asio::error::message_size)
{
if (packet_type == 0) // bs
{
int tracker_count = data_[14] * 256 + data_[13];
fout << "向bs查询到" << tracker_count << "个tracker" << std::endl;
fout.close();
has_tracker_list = true;
timer.cancel();
}
else if (packet_type == 1) // tracker
{
int peer_count = data_[28] * 256 + data_[27];
//mu.lock();
std::string result = "";
result.append("向tracker(");
result.append(m_tracker_infos[tracker_index].ip);
result.append(":");
boost::uint16_t port = m_tracker_infos[tracker_index].port;
char tmp[10];
itoa(m_tracker_infos[tracker_index].port, tmp, 10);
result.append(tmp);
result.append( ")查询到");
itoa(peer_count, tmp, 10);
result.append(tmp);
result.append("个peer");
// result += "向tracker(" + m_tracker_infos[tracker_index].ip + ":" + m_tracker_infos[tracker_index].port
// + ")查询到" + peer_count + "个peer";
result_trackers.push_back(result);
// fout << "向tracker(" << m_tracker_infos[tracker_index].ip << ":" << m_tracker_infos[tracker_index].port
// << ")查询到" << peer_count << "个peer" << std::endl;
// fout.close();
// mu.unlock();
timer.cancel();
has_peer_list = true;
}
}
else if (error != boost::asio::error::operation_aborted)
{
if (packet_type == 0)
{
fout << error.message() << std::endl;
fout.close();
}
else if (packet_type == 1)
{
result_trackers.push_back(error.message());
}
}
}
开发者ID:huangyt,项目名称:MyProjects,代码行数:55,代码来源:Detection.cpp
示例7: AsyncLoopTimer
void AsyncLoopTimer(boost::function<TaskState()> doWork, boost::asio::deadline_timer& dTimer, int millisecs)
{
TaskState st = doWork();
if (st == TASK_WORKING)
{
dTimer.expires_from_now(boost::posix_time::milliseconds(millisecs));
dTimer.async_wait(boost::bind(AsyncLoopTimer, doWork, boost::ref(dTimer), millisecs));
}
// Work is over; nothing to do, as the timer is not rearmed
}
开发者ID:PauloCaetano,项目名称:SimpleSampleTuts,代码行数:12,代码来源:asyncloop.cpp
示例8: checkDeadLine
void checkDeadLine()
{
if (deadline_.expires_at() <= boost::asio::deadline_timer::traits_type::now())
{
if (yawAdj_ != 0.0 || heigthAdj_ != 0.0) {
drone_.Yaw(drone_.Yaw() + yawAdj_);
drone_.H(drone_.H() + heigthAdj_);
drone_.SendCmd();
}
deadline_.expires_from_now(boost::posix_time::milliseconds(50));
}
deadline_.async_wait(boost::bind(&JoystickDroneHandler::checkDeadLine, this));
}
开发者ID:djtrance,项目名称:ardrone,代码行数:13,代码来源:Console.cpp
示例9: Wait
void Wait() {
if (!queue_.empty()) {
std::cout << "t0 + " << std::setw(4) << mark() << "ms Open for Number : " << type << " (dur:" << queue_.front() << ") (depth " << queue_.size() << ")\n";
timer_.expires_from_now(boost::posix_time::milliseconds(queue_.front()));
timer_.async_wait(strand_.wrap(std::bind(&Session::Close, shared_from_this())));
}
}
开发者ID:CCJY,项目名称:coliru,代码行数:7,代码来源:main.cpp
示例10: start
void start(FIFO_TYPE *audiofifo) {
m_audiofifo = audiofifo;
if(running)
return;
timer.expires_from_now(boost::posix_time::seconds(2));
timer.async_wait(timeout_handler);
}
开发者ID:ysblokje,项目名称:mumble-jukebox,代码行数:7,代码来源:player.hpp
示例11: print
void print(const boost::system::error_code& e)
{
std::cout << i++ << ": Hello, world!\n";
std::cout << e << std::endl;
t.expires_from_now(boost::posix_time::seconds(1));
t.async_wait(print);
}
开发者ID:xtwxy,项目名称:boost-reciple,代码行数:7,代码来源:main.cpp
示例12: do_timer
void do_timer(const boost::system::error_code&)
{
callback();
// reset the timer
timer.expires_from_now(checkpoint_interval);
timer.async_wait(boost::bind(&handlers::do_timer, this, _1));
}
开发者ID:andreabedini,项目名称:isaw-sq-flatperm,代码行数:8,代码来源:main.cpp
示例13: reconnect
void reconnect() {
if (m_abort || m_reconnect_secs <= 0)
return;
m_reconnect_timer.expires_from_now(boost::posix_time::seconds(m_reconnect_secs));
m_reconnect_timer.async_wait(
boost::bind(&self::timer_reconnect, this->shared_from_this(),
boost::asio::placeholders::error));
}
开发者ID:alepharchives,项目名称:eixx,代码行数:8,代码来源:basic_otp_connection.hpp
示例14: print
void Print::print() {
if (count_ < 5) {
timer_.expires_at(timer_.expires_at() + boost::posix_time::seconds(1));
timer_.async_wait(boost::bind(&Print::print, this));
}
std::cout << "wait count " << count_ << std::endl;
count_++;
}
开发者ID:vipnormalhy,项目名称:learn,代码行数:8,代码来源:member_timer.cpp
示例15: justdoit
void justdoit()
{
rc_->get(strand_.wrap(
boost::bind(&tormoz_get::handle_done, shared_from_this(), _1, _2))
);
timer_.expires_from_now(boost::posix_time::milliseconds(100));
timer_.async_wait(strand_.wrap(boost::bind(&tormoz_get::handle_timeout, shared_from_this(), _1)));
}
开发者ID:alexeimoisseev,项目名称:NwSMTP,代码行数:8,代码来源:tormoz2.cpp
示例16: on_open
void on_open() override {
auto self(shared_from_this());
std::cout << "WebSocket connection open\n";
timer_.expires_from_now(boost::posix_time::milliseconds(100));
timer_.async_wait([this, self](const boost::system::error_code &ec) {
timer_cb(ec);
});
}
开发者ID:alexyoung91,项目名称:ws,代码行数:8,代码来源:timed_server.cpp
示例17: start_timer
void start_timer(){
ping_timer->expires_at(ping_timer->expires_at() + ping_interval);
ping_timer->async_wait(boost::bind(
&sAudioReceiver::handle_timer,
this,
boost::asio::placeholders::error
));
}
开发者ID:Szperak,项目名称:sAudio-receiver,代码行数:9,代码来源:client.cpp
示例18: call_func
void call_func(const boost::system::error_code&)
{
if (count >= count_max)
return;
++count;
f();
t.expires_at(t.expires_at() + boost::posix_time::millisec(500));
t.async_wait(boost::bind(&a_timer::call_func, this,
boost::asio::placeholders::error));
}
开发者ID:opensvn,项目名称:boost_learning,代码行数:10,代码来源:tcp_sync_client.cpp
示例19: scheduleTimer
void SenderImpl::scheduleTimer(Sender_weak weak)
{
namespace ptime = boost::posix_time;
m_timer.expires_at(m_timer.expires_at() +
ptime::milliseconds(m_config->period()));
m_timer.async_wait(
boost::bind(&SenderImpl::handleTimeout,
this, weak, _1));
}
开发者ID:catedrasaes-umu,项目名称:corbasim,代码行数:11,代码来源:Sender.cpp
示例20: handlers
handlers(boost::asio::io_service& io_service, std::function<void()> callback)
: callback(callback)
, signals(io_service, SIGHUP, SIGTERM, SIGINT)
, timer(io_service)
, checkpoint_interval(boost::posix_time::hours(1))
{
signals.async_wait(boost::bind(&handlers::do_signal, this, _1, _2));
// set the timer
timer.expires_from_now(checkpoint_interval);
timer.async_wait(boost::bind(&handlers::do_timer, this, _1));
}
开发者ID:andreabedini,项目名称:isaw-sq-flatperm,代码行数:11,代码来源:main.cpp
注:本文中的boost::asio::deadline_timer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论