Boost logo

Boost Users :

From: Sergei Politov (spolitov_at_[hidden])
Date: 2008-02-12 14:38:36


I have two questions about Boost.Asio library:
1) Is it safe to invoke deadline_timer::expires_from_now in thread different
from thread where io_service is running? For instance:
===========================================
void print(const boost::system::error_code& e)
{
  std::cout << "Hello, world:" << e << "!\n";
}

void execute(boost::asio::deadline_timer & timer)
{
  timer.expires_from_now(boost::posix_time::seconds(0));
}

int main()
{
  boost::asio::io_service io;

  boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
  t.async_wait(print);

  boost::thread th(boost::bind(&execute, ref(timer)));

  io.run();

  return 0;
}
============================================
2) Are there any type of objects similar to events from WINAPI?
I.e. these objects is not signalled (handler is not invoked) until
they are signalled manually.

Obviously such objects could be emulated using deadline_timer. But it would
be great to have such objects itself.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net