<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-35024958.post8346794537143965494..comments</id><updated>2010-03-31T14:25:28.058+11:00</updated><category term='templates'/><category term='static_assert'/><category term='threads'/><category term='timer'/><category term='decltype'/><category term='sfinae'/><category term='error_code'/><category term='ssl'/><category term='c++0x'/><category term='parallelism'/><category term='boost'/><category term='iostream'/><category term='c++'/><category term='timeout'/><category term='asio'/><category term='system_error'/><category term='bind'/><category term='hardware'/><category term='coroutines'/><title type='text'>Comments on Thinking Asynchronously in C++: Composed operations, coroutines and code makeover</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.think-async.com/feeds/8346794537143965494/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html'/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-35024958.post-3327286371252062316</id><published>2010-03-31T14:25:28.054+11:00</published><updated>2010-03-31T14:25:28.054+11:00</updated><title type='text'>Note that try/catch followed by a yield on the nex...</title><content type='html'>Note that try/catch followed by a yield on the next line doesn&amp;#39;t do quite the right thing (see new post). However, you could probably write:&lt;br /&gt;&lt;br /&gt;yield try&lt;br /&gt;{&lt;br /&gt;  ...&lt;br /&gt;}&lt;br /&gt;catch (exception&amp;amp; e)&lt;br /&gt;{&lt;br /&gt;  ...&lt;br /&gt;}</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3327286371252062316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3327286371252062316'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1270005928054#c3327286371252062316' title=''/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-660467121'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-6465671027103147631</id><published>2010-02-28T20:50:24.802+11:00</published><updated>2010-02-28T20:50:24.802+11:00</updated><title type='text'>However, in regards to exception handling, the yie...</title><content type='html'>However, in regards to exception handling, the yield function can become standalone so you can do the async call (within a try/catch) before the yield, then call yield on the next line (followed by ; or {}).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/6465671027103147631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/6465671027103147631'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1267350624802#c6465671027103147631' title=''/><author><name>OvermindDL1</name><uri>http://www.blogger.com/profile/07860163774454764880</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2143462525'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-1614811221127541568</id><published>2009-11-28T07:23:04.163+11:00</published><updated>2009-11-28T07:23:04.163+11:00</updated><title type='text'>I really like your stackless coroutine implementat...</title><content type='html'>I really like your stackless coroutine implementation, there is only one thing which makes me a bit nervous - exception handling inside coroutine body. It&amp;#39;s impossible to wrap &amp;quot;yield&amp;quot; call with try...catch block(you&amp;#39;ll get &amp;quot;jump to case label enters try block&amp;quot; error) which is really disturbing.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1614811221127541568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1614811221127541568'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1259353384163#c1614811221127541568' title=''/><author><name>pachanga</name><uri>http://www.blogger.com/profile/12434709367397997534</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1010921964'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-4520350527158335693</id><published>2009-11-17T03:34:37.886+11:00</published><updated>2009-11-17T03:34:37.886+11:00</updated><title type='text'>starfish, you&amp;#39;re right but you can&amp;#39;t pass ...</title><content type='html'>starfish, you&amp;#39;re right but you can&amp;#39;t pass the lambda any initialization variables (use []), you&amp;#39;d have to bind those to onAccept when passed to async_accept.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4520350527158335693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4520350527158335693'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1258389277886#c4520350527158335693' title=''/><author><name>Eric Muyser</name><uri>http://www.blogger.com/profile/15434323864916255798</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-732641862'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-1142436948008212614</id><published>2009-11-15T02:08:21.725+11:00</published><updated>2009-11-15T02:08:21.725+11:00</updated><title type='text'></title><content type='html'>This comment has been removed by a blog administrator.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1142436948008212614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1142436948008212614'/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.contentRemoved' value='true'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2041148203'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-1925273896470652078</id><published>2009-10-26T04:55:39.525+11:00</published><updated>2009-10-26T04:55:39.525+11:00</updated><title type='text'>Btw, I think the the lambda reference problem disc...</title><content type='html'>Btw, I think the the lambda reference problem discussed above can be solved by making the onAccept static.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1925273896470652078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1925273896470652078'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1256493339525#c1925273896470652078' title=''/><author><name>starfish</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1068859686'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-1683750215672237494</id><published>2009-10-26T04:37:53.628+11:00</published><updated>2009-10-26T04:37:53.628+11:00</updated><title type='text'>Hello, I think I&amp;#39;ve found a bug in asio, compi...</title><content type='html'>Hello, I think I&amp;#39;ve found a bug in asio, compiled for win64. The following code compiles, but generates an access violation when run:&lt;br /&gt;&lt;br /&gt;std::string message = &amp;quot;This is a server message!&amp;quot;;&lt;br /&gt;boost::asio::buffer (message);</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1683750215672237494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1683750215672237494'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1256492273628#c1683750215672237494' title=''/><author><name>starfish</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1068859686'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-4601147525147246620</id><published>2009-09-08T16:37:10.753+10:00</published><updated>2009-09-08T16:37:10.753+10:00</updated><title type='text'>Hey Chris! Thanks for the response. Now I understa...</title><content type='html'>Hey Chris! Thanks for the response. Now I understand what you mean. You&amp;#39;re right about the problem calling itself. Actually you can call the lambda from itself fine, even when you leave the scope. You just can&amp;#39;t pass it as an argument and have it called from somewhere else. Which is why my last example worked, I put the h1 = h2 part to show it works when the scope ends, but I didn&amp;#39;t pass it to a function, like you would with async_accept - it would fail from within io_service&amp;#39;s run().&lt;br /&gt;&lt;br /&gt;Here&amp;#39;s async_echo:&lt;br /&gt;&lt;br /&gt;//template &amp;lt;typename Handler&amp;gt;&lt;br /&gt;void async_echo(&lt;br /&gt;  tcp::socket&amp;amp; socket,&lt;br /&gt;  mutable_buffer working_buffer,&lt;br /&gt;  //Handler handler,&lt;br /&gt;  boost::function&amp;lt;void()&amp;gt; handler,&lt;br /&gt;  error_code ec = error_code(),&lt;br /&gt;  size_t length = 0)&lt;br /&gt;{&lt;br /&gt;    socket.async_read_some(buffer(working_buffer), [&amp;amp;socket, &amp;amp;working_buffer, &amp;amp;length, handler](error_code const&amp;amp; error, int total)&lt;br /&gt;    {&lt;br /&gt;        async_write(socket, buffer(working_buffer, length), [&amp;amp;socket, &amp;amp;working_buffer, handler](error_code const&amp;amp; error, int total)&lt;br /&gt;        {&lt;br /&gt;            handler();&lt;br /&gt;        });&lt;br /&gt;    });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Apparently there&amp;#39;s a known bug with lambdas atm that they don&amp;#39;t work with templated dependent types. I&amp;#39;m sure they&amp;#39;ll fix that. Just to show it works though I used boost::function (or std::function).&lt;br /&gt;&lt;br /&gt;So yeah, you can&amp;#39;t have a gimmick all-in-one lambda server, you need to separate your loop function.&lt;br /&gt;&lt;br /&gt;I had an example finished but it segfauls due to that lambda glitch. You think they&amp;#39;ll fix these things? (2 big issues)&lt;br /&gt;&lt;br /&gt;Thanks :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4601147525147246620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4601147525147246620'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252391830753#c4601147525147246620' title=''/><author><name>Eric Muyser</name><uri>http://www.blogger.com/profile/15434323864916255798</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-732641862'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-9161586523357283844</id><published>2009-09-07T14:50:43.862+10:00</published><updated>2009-09-07T14:50:43.862+10:00</updated><title type='text'>In your snippet, both of these places:

  h2(); &amp;l...</title><content type='html'>In your snippet, both of these places:&lt;br /&gt;&lt;br /&gt;  h2(); &amp;lt;--- here&lt;br /&gt;  } //end scope&lt;br /&gt;&lt;br /&gt;  h1(); &amp;lt;--- and here&lt;br /&gt;&lt;br /&gt;will perform &amp;quot;h1 = h2;&amp;quot;. Obviously you need to do some additional housekeeping inside the lambda to make this work.&lt;br /&gt;&lt;br /&gt;I&amp;#39;d be very interested to see a more fully worked example for an async_accept loop using this approach. And, for bonus points, whether you can do a lambda-based implementation of the async_echo composed operation (working as shown in the original blog post).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/9161586523357283844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/9161586523357283844'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252299043862#c9161586523357283844' title=''/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-660467121'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-2117099110003728057</id><published>2009-09-06T11:51:46.127+10:00</published><updated>2009-09-06T11:51:46.127+10:00</updated><title type='text'>Oh right, I gotcha. A lambda can&amp;#39;t copy itself...</title><content type='html'>Oh right, I gotcha. A lambda can&amp;#39;t copy itself by value in the initializer list (only by reference), but from within itself it can copy itself can&amp;#39;t it? Which is where you would be calling the async operation (passing itself, ie. a copy). How would there be a danging reference then?&lt;br /&gt;&lt;br /&gt;    std::function&amp;lt;void()&amp;gt; h1;&lt;br /&gt;&lt;br /&gt;    { //begin scope&lt;br /&gt;        std::function&amp;lt;void()&amp;gt; h2 = [&amp;amp;]()&lt;br /&gt;        {&lt;br /&gt;            cout &amp;lt;&amp;lt; &amp;quot;Hello world!&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;            h1 = h2;&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        h2();&lt;br /&gt;    } //end scope&lt;br /&gt;&lt;br /&gt;    h1();&lt;br /&gt;&lt;br /&gt;So I might not be understanding because I don&amp;#39;t see what&amp;#39;s wrong with that. h2 is the lambda, h1 is the async_accept/etc argument. Either way I imagine there would be some additional overhead using lambdas. Although I guess that&amp;#39;s the case either way.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/2117099110003728057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/2117099110003728057'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252201906127#c2117099110003728057' title=''/><author><name>Eric Muyser</name><uri>http://www.blogger.com/profile/15434323864916255798</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-732641862'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-8891452154711569940</id><published>2009-09-06T09:29:12.544+10:00</published><updated>2009-09-06T09:29:12.544+10:00</updated><title type='text'>This code captures the lambda variable (&amp;quot;onAc...</title><content type='html'>This code captures the lambda variable (&amp;quot;onAccept&amp;quot;) by reference. This means you will have a dangling reference in the completion handler as soon as you leave the scope where the async operation was started.&lt;br /&gt;&lt;br /&gt;For it to work, you need to store a copy of the lambda object, but a lambda cannot capture a copy of itself.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/8891452154711569940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/8891452154711569940'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252193352544#c8891452154711569940' title=''/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-660467121'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-3431555873417644503</id><published>2009-09-06T01:38:04.217+10:00</published><updated>2009-09-06T01:38:04.217+10:00</updated><title type='text'>Oh, I personally find lambdas more readable, since...</title><content type='html'>Oh, I personally find lambdas more readable, since they are akin to inline functions, and closures of other languages. If you declare them by name, they appear almost exactly the same as normal functions.&lt;br /&gt;&lt;br /&gt;What do you mean lambdas can&amp;#39;t perform loops of asynchronous operations? Do you mean:&lt;br /&gt;&lt;br /&gt;tcp::socket socket(io_service_);&lt;br /&gt;tcp::acceptor acceptor(io_service_);&lt;br /&gt;&lt;br /&gt;auto onAccept = [&amp;amp;](tcp::socket&amp;amp; socket, error_code ec)&lt;br /&gt;{&lt;br /&gt;handler(ec);&lt;br /&gt;&lt;br /&gt;acceptor.async_accept(socket, onAccept);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;acceptor.async_accept(socket, onAccept);&lt;br /&gt;&lt;br /&gt;Same as how your coroutine example goes from top to bottom over and over (looping). I don&amp;#39;t think any form of recursion (or &amp;quot;loops&amp;quot;) work at the moment, but it&amp;#39;s in the standard proposal.&lt;br /&gt;&lt;br /&gt;Still, there&amp;#39;s a few caveats with c++0x lambdas. I&amp;#39;m just trying to understand the benefits of coroutines in comparison.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3431555873417644503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3431555873417644503'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252165084217#c3431555873417644503' title=''/><author><name>Eric Muyser</name><uri>http://www.blogger.com/profile/15434323864916255798</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-732641862'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-7973425030352906260</id><published>2009-09-05T22:22:24.374+10:00</published><updated>2009-09-05T22:22:24.374+10:00</updated><title type='text'>In my opinion, coroutines are more readable. More ...</title><content type='html'>In my opinion, coroutines are more readable. More important, however, is that they are capable of complex control flow, such as loops. Lambdas can&amp;#39;t do loops of async operations within a single function.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/7973425030352906260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/7973425030352906260'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252153344374#c7973425030352906260' title=''/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-660467121'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-869696596389478098</id><published>2009-09-05T21:47:46.531+10:00</published><updated>2009-09-05T21:47:46.531+10:00</updated><title type='text'>Lambdas ARE code liposuction, but if your compiler...</title><content type='html'>Lambdas ARE code liposuction, but if your compiler is capable of lambdas, why wouldn&amp;#39;t you just use those instead of coroutines? ie. something like... &lt;br /&gt;&lt;br /&gt;socket.async_read_some(buffer(working_buffer), [&amp;amp;](tcp::socket&amp;amp; socket, error_code ec) &lt;br /&gt;{ &lt;br /&gt;  async_write(socket, buffer(working_buffer, length), [&amp;amp;](tcp::socket&amp;amp; socket, error_code ec) &lt;br /&gt;  { &lt;br /&gt;    handler(ec);&lt;br /&gt;  });&lt;br /&gt;});</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/869696596389478098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/869696596389478098'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1252151266531#c869696596389478098' title=''/><author><name>Eric Muyser</name><uri>http://www.blogger.com/profile/15434323864916255798</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-732641862'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-3978103905060363852</id><published>2009-08-14T14:17:37.013+10:00</published><updated>2009-08-14T14:17:37.013+10:00</updated><title type='text'>Understood. Thanks Chris. Asio rulez!</title><content type='html'>Understood. Thanks Chris. Asio rulez!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3978103905060363852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/3978103905060363852'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1250223457013#c3978103905060363852' title=''/><author><name>Chila</name><uri>http://www.blogger.com/profile/13740808336152664145</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-183905826'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-6932758457980509494</id><published>2009-08-14T10:55:52.739+10:00</published><updated>2009-08-14T10:55:52.739+10:00</updated><title type='text'>The proposed boost::coroutine library provides sta...</title><content type='html'>The proposed boost::coroutine library provides stackful coroutines (vs the stackless ones I showed).&lt;br /&gt;&lt;br /&gt;The advantage of having a stack is that you can yield from a nested function, which means you can layer non-async-aware APIs (e.g. a boost.spirit parser) over the top of async calls.&lt;br /&gt;&lt;br /&gt;However, one of the disadvantages is that you have a stack :)&lt;br /&gt;&lt;br /&gt;You can&amp;#39;t transparently implement composed operations using stackful coroutines because you have to pass the coroutine&amp;#39;s &amp;quot;self&amp;quot; reference to the function. (Well actually you could do it by creating a new coroutine stack for each composed operation, but that could be quite expensive.)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/6932758457980509494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/6932758457980509494'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1250211352739#c6932758457980509494' title=''/><author><name>chris</name><uri>http://www.blogger.com/profile/09159109667366328919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-660467121'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-4565877125316883035</id><published>2009-08-14T07:31:50.311+10:00</published><updated>2009-08-14T07:31:50.311+10:00</updated><title type='text'>What do you think about this boost::coroutine?

ht...</title><content type='html'>What do you think about this boost::coroutine?&lt;br /&gt;&lt;br /&gt;http://www.crystalclearsoftware.com/soc/coroutine</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4565877125316883035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/4565877125316883035'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1250199110311#c4565877125316883035' title=''/><author><name>Chila</name><uri>http://www.blogger.com/profile/13740808336152664145</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-183905826'/></entry><entry><id>tag:blogger.com,1999:blog-35024958.post-1395130255265434248</id><published>2009-08-13T11:44:57.588+10:00</published><updated>2009-08-13T11:44:57.588+10:00</updated><title type='text'>Cool!</title><content type='html'>Cool!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1395130255265434248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35024958/8346794537143965494/comments/default/1395130255265434248'/><link rel='alternate' type='text/html' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html?showComment=1250127897588#c1395130255265434248' title=''/><author><name>Chila</name><uri>http://www.blogger.com/profile/13740808336152664145</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.think-async.com/2009/08/composed-operations-coroutines-and-code.html' ref='tag:blogger.com,1999:blog-35024958.post-8346794537143965494' source='http://www.blogger.com/feeds/35024958/posts/default/8346794537143965494' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-183905826'/></entry></feed>
