On 10/20/17 2:40 AM, Suliman wrote:

How runtime detect blocking operation? Is it's some auto-detection or programmer should call yield every time when he expect blocking operation.

Ok, for example we got blocking operation (for example file-reading). The fiber is doing yield. But file reading can't be run in nowhere. It should be run in thread. But where is this thread?

It works on an event loop. In essence, the fiber is "put to sleep", and
the event library is used to wake it back up when data is ready. All of
it is run in the same thread I believe.

If you are familiar with using select() it looks something like this
(this is my conception anyway, not familiar intimately with the
implementation):

while(true)
{

// run all runnable fibers until yield or registers blocking fd
// with listOfFds
fibers.run();
int fdready;
while((fdready = select(listOfFds, 0)) >= 0) // looks for all file
                                             // descriptors that are
                                             // ready with input
{
   fibers.wakeUpForFD(fdready);
}

}

What is the difference between D and Go approche?

No idea how Go works.

-Steve