From: Oleg M. <ole...@gm...> - 2011-01-12 04:24:35
|
Hello, Dean, Here is my implementation of async_connection::write_vec(). Before any pull requests I want you to check it to see if you like the idea. First of all, current write_impl() introduces race on user data. If execution flow falls in one of conditions when we need to wait for headers being sent than we schedule an operation and return control to user _without_ copying the data. The actual copying will occur after continue_write(). Being not hardcore-templating-guru I don't know how to make specific write() overload with ConstBufferSequence model as a first argument (because it overlaps with <Range, Callback>) so I introduced write_vec interface. BTW, I think it is a good idea to explicitly specify that write() makes a copy of supplied data and rename it to write_copy() (see to_lower_copy, to_upper_copy, etc. in boost::algorithm) To maximise core reuse, write_impl now only prepares buffers and passes them to write_vec_impl. Tested both write and write_vec on 'master' with valgrind on linux/amd64: no memory leaks, no memory corruption. Patch provided applies cleanly to master and 0.9-devel. -- Best regards, Oleg Malashenko. |