Most tutorials I have seen for Node JS/ReactPHP is more like, that you don't need to wait a 5 seconds timer to echo something. EventLoop can handle that later.
Like This Example Below (Note this is non-language dependent):
timer(run 5 seconds later){
print 'username';
}
print ', another text';
// non A-Sync output is like = 'username, another request'
// A-Sync output is like = ', another requestusername'
But this is the same file we are working inside. What if we connect to a i/o socket.
Like This Example: (requestfile.js)
connectSocket(takes 5 seconds to return a result){
print result;
}
//end of the file
Well I have 2 Questions here (doesnt matter reactphp or nodejs, async matters for me)
1-If we get 2 user requests, the first one connects and waits 5 seconds, can A-Sync run the second request in this same thread while waiting respond callback for the first Request. (or does async only mean, you can do independent operations inside same file like: print footer while connecting this socket for 5 seconds)
2-In Which Core/Thread is EventLoop running? Is it Independent from request Thread. If Not How Don't We Loose Eventloop Process? Who Is(Thread/Core) controlling that, if the socket returned a value? Is EventLoop maybe running every second to check callbacks? (I thought, doesn't matter how fast it is but machine code is running linear synced (one after another))