|
Boost Users : |
Subject: Re: [Boost-users] Using boost::asio::async_write to stream out data
From: Alex Black (alex_at_[hidden])
Date: 2009-07-17 19:32:41
So, If I'm calling aysnc_write from the same thread each time, and I'm not waiting for previous writes to complete before starting a new write, how do I know when to free my buffer?
The problem seems to be that the handle_write method will be called to let me know when the write is complete, but I won't have any information in handle_write to know *which* buffer to free... any suggestions?
thx
- Alex
________________________________
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Matheus Araújo Aguiar
Sent: Friday, July 17, 2009 2:11 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Using boost::asio::async_write to stream out data
3. I understand I can't call async_write again before the first one has
been completed (since I don't want my 8kb chunks interleaved), so should
I maintain a queue of buffers waiting to go out?
Then in my handle_write method should I check the queue, if at least one
buffer is in the queue then I should start a new async_write?
Well, i don't know how to answer this one, and maybe that's the problem i'm having right now with my tcp async write code, then i'm so confused as you.
Actually, after thinking a little i guess it is this: If you call async_write from the same thread, then you should not worry about your chunks getting interleaved. But that's not the case if you call async_write from more that one thread and to prevent that you could use a mutex.
Hope it helps,
Kindly,
--
Matheus Araújo Aguiar
Computer Scientist
matheus.pit_at_[hidden]
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