Boost logo

Boost Users :

Subject: [Boost-users] multithreaded timer?
From: Francisco Ares (frares_at_[hidden])
Date: 2009-03-26 05:40:08


I'm implementing an application, serial RS232 communications centered,
using boost in Windows.

Many of the user actions are translated to ASCII commands to be sent
to some serial devices connected to the serial ports, but as they are
quite slow, I had to implement a command queue, so that as soon as a
command gets its answer, it is cleared and the next one is sent, up to
the end of the queue (of course).

Using boost serial communication features, I realized that I needed an
extra time-out, because the devices are real slow.

So that this low speed doesn't lock up anything, the command queue
runs in a separate thread and I would like another thread to run a
timer, that could be activated when the command is send by the queue
thread, and deactivated by the same thread if it detects an answer
coming from the device in response to its command. If the timer is
due, it should send a signal or call a callback function in the queue
thread so it knows that the last command timed-out and it should
re-send it again.

All the queue things are OK (so it seems for now), I just need the timer.

The ASIO timer is quite strange to me, I didn't manage to make it
work. I have already seen the "timers" tutorials at boost web pages,
and none have worked for me as expected.

Any ideas / suggestions / snippets?

Thanks a lot

"If you have an apple and I have an apple and we exchange apples then
you and I will still each have one apple. But if you have an idea and
I have one idea and we exchange these ideas, then each of us will have
two ideas." - George Bernard Shaw

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at