4 ms·
this is interesting. could you show (or point to a good example) of how GO handles this w/out reentry points? I mean you have to tell it where to return the res
by SonicSoul 10y ago
this is interesting. could you show (or point to a good example) of how GO handles this w/out reentry points? I mean you have to tell it where to return the results somehow
- lossolo 10y agoIt really depends on your app logic. If you need to process data in waterfall like model and you have multiple tasks working in same time you still need to use asynchronous calls or you will lock the execution of code in node. In go you just lock the gorutine in which you make I/O call.
- hellcow 10y agoGoroutines communicate data via channels, so you can just pass a channel a message (which can be anything). The channel will sit and wait for a message, processing the message when it's received. That said, for anything like a website or an API you probably won't need to worry much about channels or concurrency at all. The stdlib handles each web request on a different goroutine, so you write synchronous code, yet your server is concurrent.
- SonicSoul 10y agoah yes! This behavior is also supported in Javascript but not as natively as in GO. But there are CSP libraries out there :) http://jlongster.com/Taming-the-Asynchronous-Beast-with-CSP-in-JavaScript http://jlongster.com/Taming-the-Asynchronous-Beast-with-CSP-...