Boost logo

Boost Users :

Subject: Re: [Boost-users] ASIO async IO, will the buffer corrupt?
From: Lloyd (lloyd_at_[hidden])
Date: 2010-05-25 04:45:56


Thank you Rutger for suggesting the idea...

----- Original Message -----
From: "Rutger ter Borg" <rutger_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Friday, May 21, 2010 3:25 PM
Subject: Re: [Boost-users] ASIO async IO, will the buffer corrupt?

> Lloyd wrote:
>
>> Hello,
>> we are trying to write a high performane storage server. For that we
>> are
>> using Aynchronous IO with boost::asio. The data will be received at the
>> storage server with the help of boost::asio::async_read(), and the data
>> will be written to the storage with boost::asio::async_write() in the
>> asyn_read() completion handler. Here we are planning to share the data
>> buffer. The async read will be running in a loop, so if the write is
>> not
>> completed and if the next async_read() attempts to access the buffer,
>> will the buffer be corrupted?
>
> Yes.
>
>>
>> If we use seperate buffer for each async_read()+async_write() operation,
>> wouldn't it be inefficient?
>>
>
> It's as efficient, it only takes more memory. What happens if the reads go
> faster than the writes? It sounds like you use a typical producer/consumer
> pattern and could use off-the-shelf solutions for that, like, e.g., a
> circular buffer.
>
> Cheers,
>
> Rutger
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

______________________________________
Scanned and protected by Email scanner


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