本文整理汇总了C++中boost::asio::deadline_timer::async_wait方法的典型用法代码示例。如果您正苦于以下问题:C++ deadline_timer::async_wait方法的具体用法?C++ deadline_timer::async_wait怎么用?C++ deadline_timer::async_wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::deadline_timer
的用法示例。
在下文中一共展示了deadline_timer::async_wait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
po::options_description desc("Options");
desc.add_options()
("port,p", po::value<int>(), "Port")
("fifo_size,F", po::value<int>(), "FIFO size")
("fifo_low_watermark,L", po::value<unsigned int>(), "FIFO low watermark")
("fifo_high_watermark,H", po::value<unsigned int>(), "FIFO high watermark")
("buf_len,X", po::value<unsigned int>(), "Buffer length")
("tx_interval,i", po::value<int>(), "Mixer call interval");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("port"))
port = vm["port"].as<int>();
if (vm.count("fifo_size"))
fifo_size = vm["fifo_size"].as<int>();
fifo_high = fifo_size;
if (vm.count("fifo_low_watermark"))
fifo_low = vm["fifo_low_watermark"].as<unsigned int>();
if (vm.count("fifo_high_watermark"))
fifo_high = vm["fifo_high_watermark"].as<unsigned int>();
if (vm.count("buf_len"))
buf_len = vm["buf_len"].as<unsigned int>();
if (vm.count("tx_interval"))
tx_interval = vm["tx_interval"].as<int>();
tcp_endpoint = tcp::endpoint(tcp::v6(), port);
udp_endpoint = udp::endpoint(udp::v6(), port);
acceptor = tcp::acceptor(io_service, tcp_endpoint);
udp_socket = udp::socket(io_service, udp_endpoint);
tcp_socket = new tcp::socket(io_service);
acceptor.listen();
acceptor.async_accept(*tcp_socket, receive_connection);
udp_socket.async_receive_from(ba::buffer(buffer), client_udp_endpoint, read_udp_data);
connection_timer.async_wait(check_connections);
report_timer.async_wait(generate_report);
signals.async_wait(signal_received);
broadcast_timer.expires_from_now(boost::posix_time::milliseconds(tx_interval));
broadcast_timer.async_wait(broadcast_data);
io_service.run();
}
示例2: 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);
}
示例3: 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())));
}
}
示例4: 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);
}
示例5: 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));
}
示例6: 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) ) );
}
示例7: MyClass
MyClass(boost::asio::io_service& io) :
m_timer(io, boost::posix_time::seconds(1)),
m_count(0)
{
m_timer.async_wait(boost::bind(&MyClass::print, this));
std::cout << "MyClass() - " << strDate() << "\n";
}
示例8: 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));
}
}
示例9: f
a_timer(boost::asio::io_service &ios, int x, F func):
f(func), count_max(x), count(0),
t(ios, boost::posix_time::millisec(500))
{
t.async_wait(boost::bind(&a_timer::call_func, this,
boost::asio::placeholders::error));
}
示例10: TimerHandler
TimerHandler(Network::IOService *io, SentMessage *messageInfo, const Duration& num_seconds)
: mTimer(*static_cast<boost::asio::io_service*>(io), boost::posix_time::microseconds(num_seconds.toMicroseconds())) {
mSentMessage = messageInfo;
mTimer.async_wait(
boost::bind(&TimerHandler::timedOut, this, boost::asio::placeholders::error));
}
示例11: 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)));
}
示例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: 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));
}
示例14: 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));
}
示例15: 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);
});
}