Boost logo

Boost Users :

Subject: [Boost-users] [asio] Synchronous/Asynchronous pattern
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2009-03-10 04:44:51


In an application we would like to support synchronous operations in the
application layer, whereas operations below it are done with asynchronous
operations. Callback handlers are not appropriate in this case,

To make the example more clear, suppose you have a remote_vector which you
would like to iterate through,

remote_vector a(10);
for( int i=0; i<10; ++i ) {
  std::cout << a[i] << std::endl;
}

here, a[i] will cause messages to be sent to retrieve the actual vector data
before printing it. The network layer is hidden from the user.

What is the best way to "emulate" synchronous behaviour with asio? The
thread running this iteration should not block, but do other work (at the
io_service?) until the requested results are received.

Many thanks,
Kind regards,

Rutger ter Borg


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