Boost logo

Boost Users :

Subject: [Boost-users] [asio] async_read_until'smatch_condition requirements/guarantees
From: Maxim Yanchenko (maximyanchenko_at_[hidden])
Date: 2010-03-18 05:22:10


Hi Chris/All,

I didn't find anything about this in the docs, so asking here.
Why I'm asking: for some protocols matching condition can be pretty complex and
will include some parsing of a partially received message. It would be great to
reuse information that was already parsed, to avoid parsing same things many
times. Also, when we finally received the whole message and match_condition
returns true, the handler is invoked which will do mostly the same parsing that
was already made by the match_condition - this is also a thing that would be
great to avoid.

1) Is the same match_condition object used every time, or multiple copies can be
created?
2) Does the state of the match_condition object persist between different
condition checks?
3) How match_condition is used if we have several threads? Should I protect
access to the state with this regard?
4) In which thread match_condition is executed? is it internal asio thread or
one of the threads that called io_service.run()?
5) What if I call the handler code right in the match_condition if the condition
is met? In this case I can reuse data I already extracted while checking the
condition, and will also avoid waiting for my handler in the asio queue.
6) Same as 5), with one addition - what if I have only one thread that calls
io_service.run()?

Of course I can figure out all this stuff from the source code, but it's
obviously subject to change, so I would better rely on something more stable,
like docs (would be great to eventually have answers to the above questions in
the docs).

Thanks,
Maxim


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