本文整理汇总了C++中boost::asio::deadline_timer类的典型用法代码示例。如果您正苦于以下问题:C++ deadline_timer类的具体用法?C++ deadline_timer怎么用?C++ deadline_timer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了deadline_timer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例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));
}
示例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) ) );
}
示例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)));
}
示例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)));
}
}
示例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());
}
}
}
示例7: 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())));
}
}
示例8: 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);
}
示例9: 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);
}
示例10: 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));
}
示例11: 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));
}
示例12: 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_++;
}
示例13: 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)));
}
示例14: 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);
});
}
示例15: 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
));
}