{"id":5151,"date":"2015-12-02T13:00:23","date_gmt":"2015-12-02T13:00:23","guid":{"rendered":"http:\/\/writeasync.net\/?p=5151"},"modified":"2015-12-02T05:25:39","modified_gmt":"2015-12-02T05:25:39","slug":"coroutines-in-c","status":"publish","type":"post","link":"https:\/\/writeasync.net\/?p=5151","title":{"rendered":"The wait is over: coroutines in C++"},"content":{"rendered":"<p><a href=\"http:\/\/writeasync.net\/?p=1901\">Long ago, I wrote<\/a> about using the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dd492418.aspx\">PPL<\/a> to achieve a .NET 4.0 level of parity for async programming in C++. Since then, a lot of work has gone into raising this level of parity to .NET 4.5 and beyond. Introducing&#8230; <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2015\/11\/30\/coroutines-in-visual-studio-2015-update-1.aspx\">C++ coroutines<\/a>.<\/p>\n<p>Sure, there have been <a href=\"http:\/\/blog.think-async.com\/2009\/08\/secret-sauce-revealed.html\">various tricks<\/a> and <a href=\"http:\/\/jrb-programming.blogspot.com\/2013\/04\/c-style-asyncawait-in-c-part-1.html\">extensions<\/a> to approximate this in the past. But this is actually ending up <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2015\/p0057r1.pdf\">in the C++ standard<\/a>!<\/p>\n<p><a href=\"https:\/\/twitter.com\/GorNishanov\">Gor Nishanov<\/a>, a major champion\/designer of this new feature, describes <a href=\"https:\/\/www.youtube.com\/watch?v=_fu0gx-xseY\">coroutines as a negative overhead abstraction<\/a>, where you end up with something &#8220;not only simpler, shorter, neater, tighter than before, but also much faster.&#8221; (He also spends a good amount of time on the origins of coroutines via Melvin Conway, which I also <a href=\"http:\/\/writeasync.net\/?p=4321\">previously wrote about<\/a>.)<\/p>\n<p>For a few practical samples, you can peruse the following resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/magazine\/mt573711.aspx\">Windows with C++ &#8211; Coroutines in Visual C++ 2015<\/a><\/li>\n<li><a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2014\/11\/12\/resumable-functions-in-c.aspx\">Resumable functions in C++<\/a> (older, uses preview keywords)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Long ago, I wrote about using the PPL to achieve a .NET 4.0 level of parity for async programming in C++. Since then, a lot of work has gone into raising this level of parity to .NET 4.5 and beyond.&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,101],"tags":[],"class_list":["post-5151","post","type-post","status-publish","format-standard","hentry","category-async","category-native"],"_links":{"self":[{"href":"https:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts\/5151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5151"}],"version-history":[{"count":0,"href":"https:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts\/5151\/revisions"}],"wp:attachment":[{"href":"https:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}