Tips and Tricks

Consider using std::vector<> for buffers over raw arrays and boost::array

A buffer variable for use with read and write operations could be defined:

  char buffer[max_size];

or:

  boost::array<char, max_size> buffer;

or:

  std::vector<char> buffer(max_size);

Consider using this last form based on std::vector<>, as it allows your application to use buffer debugging.

Repeating timers

Asio has a rather good deadline timer, but try using it as a repeating timer and you will come into difficulties when attempting to cancel it.

This is an interesting example of an implementaion of a repeating timer which is basd on the basic_deadline_timer and uses its implementaion and service to acheive a safe repeating time which is cancellable. This timer provides a guarante that the async callback will not be invoked when the cancel returns.

Edit | Attach | Print version | History: r7 | r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 18 Feb 2009 - 15:15:03 - DavidWyles?
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback