[{"data":1,"prerenderedAt":296},["ShallowReactive",2],{"project-39971984":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":43,"post_text":46,"what":47,"said":61,"maker_in_thread":166,"shape":171,"grid":174,"attempts":257,"same_week":258,"maker_shows":222,"maker_hidden":288,"reader_version":289,"card":290},"39971984","Neco","Coroutine Library for C","title","Show HN: Neco – Coroutine Library for C","https:\u002F\u002Fgithub.com\u002Ftidwall\u002Fneco","github.com","tidwall",1712597864,2024,145,36,584,3515,17,"notable","languages","coroutine library","library",[24,25,26,27],"c coroutines","stackful coroutines","green threads","cooperative multitasking","loved",0.185,{"positive":31,"neutral":32,"mixed":33,"critical":33},4,10,0,14,{"design":36,"idea":38,"execution":39,"performance":41,"docs":42},{"positive":37,"critical":33},2,{"positive":33,"critical":33},{"positive":40,"critical":33},1,{"positive":40,"critical":33},{"positive":33,"critical":33},[33,33,33,33,44,45,33,33,45,33,33,44,45,33,44,33,45,45,44,33,33,33,33,33,33,33,33,33,33,33,45,45,45,33,45,45],5,3,null,{"problem":46,"audience":46,"pricing":46,"motivation":46,"time_to_build":46,"stack":48,"openness":59,"stage":60,"team_size":60},[49],{"value":50,"source":51,"evidence":52},"C","inferred",[53,55],{"id":54},"post",{"id":56,"by":57,"text":58},"39985214","dkjaudyeqooe","These are stackful coroutines, as opposed to stackless. Stackful coroutines create a new stack for each coroutine thread and save and restore the appropriate registers when…","open_source","unknown",{"praise":62,"objections":90,"requests":112,"questions":123,"alternatives":146},[63,79],{"value":64,"source":65,"evidence":66},"Simple, elegant API and clean code","commenter",[67,71,75],{"id":68,"by":69,"text":70},"39972334","plagiat0r","I love how simple and elegant is this to use: https:\u002F\u002Fgithub.com\u002Ftidwall\u002Fneco\u002Fblob\u002Fmain\u002Fexamples\u002Fecho-server.c I was going to actually implement an echo server for load balancer…",{"id":72,"by":73,"text":74},"39984790","trebecks","yeah i like this model. then you can use whatever synchronization junk you prefer to share state between the threads, if you have any. your library looks well written and clean.…",{"id":76,"by":77,"text":78},"39985332","btilly","This library aims to be the simplest and most efficient thing for what it does. And what it does is perfect for is managing communications with things that themselves may be…",{"value":80,"source":65,"evidence":81},"Useful for I\u002FO-bound work and multiplexing on a thread",[82,85,89],{"id":83,"by":73,"text":84},"39984350","the scheduler is probably simpler if coroutines can't bounce between cores. you can have a single thread per core that runs the scheduler to multiplex a bunch of coroutines on…",{"id":86,"by":87,"text":88},"39984762","LoganDark","Coroutines are still very useful for multitasking even if you're not sharing tasks between CPU cores. Other coroutines can just execute whenever something would normally block,…",{"id":76,"by":77,"text":78},[91,102],{"value":92,"source":65,"evidence":93},"Coroutines are not goroutines; no multi-core scheduling by default",[94,98],{"id":95,"by":96,"text":97},"39984200","dingdingdang","Can someone help elucidate why \"It's a non-goal for Neco to provide a scalable multithreaded runtime, where the coroutine scheduler is shared among multiple cpu cores [...]\" this…",{"id":99,"by":100,"text":101},"39985111","samatman","Goroutines aren't coroutines. This isn't a nitpick, it's pretty essential to understanding the goals and non-goals of Neco. Coroutines are a control-flow primitive which allows…",{"value":103,"source":65,"evidence":104},"Debate over whether it truly provides symmetric\u002Fasymmetric coroutine semantics",[105,109],{"id":106,"by":107,"text":108},"39988843","nialv7","I think the replies l got here more or less proves my point. So a coroutine is basically something you can explicitly yield control flow from or give control flow to. neco…",{"id":110,"by":100,"text":111},"39991068","These are coroutines. Just... look at the code, this isn't a proprietary binary product where you have to take someone's word for it. They're very clearly coroutines. I don't…",[113],{"value":114,"source":65,"evidence":115},"Clarify the naming and documentation of coroutine semantics",[116,119],{"id":117,"by":107,"text":118},"39985555","These are cooperatively scheduled green threads... I feel the word \"coroutine\" is slowly losing its original meaning, similar to what happened to \"lambda\".",{"id":120,"by":121,"text":122},"39988409","Karellen","In \"Example 4\", I don't understand where the \"arg2\" in `free(arg2)` is coming from?",[124,135],{"value":125,"source":65,"evidence":126},"How does it work on WebAssembly without native stack switching?",[127,131],{"id":128,"by":129,"text":130},"39986812","comex","How does it work on WebAssembly, where there's no native support for stack switching? Does it rely on Emscripten's Asyncify transformation?",{"id":132,"by":133,"text":134},"39986851","StayTrue","Yes according to the caveats section in the llco subproject: > Webassembly: Must be compiled with Emscripten using the -sASYNCIFY flag.",{"value":136,"source":65,"evidence":137},"How does neco_sleep avoid saturating the CPU?",[138,142],{"id":139,"by":140,"text":141},"39985379","burntcaramel","Can someone explain how this works please? How does it prevent this from saturating the CPU? ``` while (1) { neco_sleep(NECO_SECOND*2); printf(\"tock\\n\"); } ```",{"id":143,"by":144,"text":145},"39985754","swatcoder","I encourage you to dig through the source. There's not that much. Either this is a library you might use, so you should obviously review the code before you include it in your…",[147,155,159],{"value":148,"source":65,"evidence":149},"libaco",[150,154],{"id":151,"by":152,"text":153},"39986092","jonhohle","I’ve used libaco with a lot of success in the past (mixing uv, curl, and zlib in a way that made the zlib loop easier to manage (since it looked like a normal read, decompress…",{"id":72,"by":73,"text":74},{"value":156,"source":65,"evidence":157},"libco",[158],{"id":72,"by":73,"text":74},{"value":160,"source":65,"evidence":161},"Bunki",[162],{"id":163,"by":164,"text":165},"39988849","anfilt","It's a little lower level than what you have, but you may find somethings interesting here: https:\u002F\u002Fgithub.com\u002FKeith-Cancel\u002FBunki",{"comments":40,"answered":33,"key":167},[168],{"id":169,"text":170},"39984574","Also it is possible to start multiple Neco schedulers in different threads, there’s an example in the readme.",{"commenters":172,"max_depth":31,"maker_replies":40,"first_comment_mins":18,"lifespan_hours":173},26,45,[175,177,181,184,186,188,192,196,199,201,203,204,206,207,208,209,212,215,216,219,221,224,227,230,233,235,237,238,240,242,244,247,249,251,255,256],[56,33,33,176,57,33],"commenter\u002Fpositive\u002Fidea",[178,33,33,179,180,33],"39986000","commenter\u002Fneutral\u002Fidea","liuliu",[182,33,33,179,183,33],"39988169","styren",[185,33,33,179,57,33],"39989666",[68,40,44,187,69,33],"project\u002Fpositive\u002Fdesign",[189,37,45,190,191,33],"39972144","maker\u002Fneutral\u002Fidea","keepamovin",[193,45,33,194,195,33],"39985411","other\u002Fneutral\u002Fnone","andrekandre",[197,45,33,194,198,33],"39987001","ReleaseCandidat",[95,31,45,200,96,33],"project\u002Fneutral\u002Fidea",[83,31,33,202,73,33],"commenter\u002Fneutral\u002Fperformance",[169,31,33,187,11,40],[72,31,44,205,73,33],"project\u002Fpositive\u002Fexecution",[86,31,45,200,87,33],[99,31,33,179,100,33],[76,31,44,187,77,33],[210,31,33,211,57,33],"39986072","commenter\u002Fneutral\u002Fdesign",[213,31,45,200,214,33],"39986704","anonymoushn",[151,44,45,200,152,33],[217,44,44,218,57,33],"39986156","project\u002Fpositive\u002Fperformance",[163,220,33,194,164,33],6,[117,222,33,223,107,33],7,"other\u002Fcritical\u002Fidea",[225,222,33,194,226,33],"39985847","wavemode",[228,222,33,194,229,33],"39985917","animaomnium",[231,222,33,194,232,33],"39985951","bee_rider",[234,222,33,179,100,33],"39986016",[106,222,33,236,107,33],"commenter\u002Fcritical\u002Fidea",[110,222,33,179,100,33],[239,222,33,179,57,33],"39986136",[241,222,33,179,107,33],"39988911",[243,222,33,179,57,33],"39989447",[128,245,45,246,129,33],8,"project\u002Fneutral\u002Fperformance",[132,245,45,248,133,33],"project\u002Fneutral\u002Fdocs",[120,250,45,248,121,33],9,[252,250,33,253,254,33],"39988619","commenter\u002Fneutral\u002Fdocs","dividuum",[139,32,45,246,140,33],[143,32,45,248,144,33],[],[259,264,269,274,279,284],{"id":260,"name":261,"points":262,"category":263},"39976640","I made a discrete logic network card",541,"hardware",{"id":265,"name":266,"points":267,"category":268},"39980222","PriceLevel",532,"web_saas",{"id":270,"name":271,"points":272,"category":273},"39992817","Sonauto",454,"ai",{"id":275,"name":276,"points":277,"category":278},"39960537","pgmock",379,"dev_tools",{"id":280,"name":281,"points":282,"category":283},"39990346","ADS-B",339,"data",{"id":285,"name":286,"points":287,"category":278},"39955944","drawDB",311,false,"v2",{"id":291,"name":5,"line":6,"ai":288,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":292,"top":18,"kw":293,"maker":11,"domain":10,"tier":19,"attempts":33,"strip":294,"url":9,"mix":295,"praise":64,"objection":92,"sub":21},39971984,0.19,[24,25,26,27],"000053003005305033500000000000333033",[31,32,33,33],1794036652680]