Re: [Factor-talk] Co-operative threading

2019-09-14 Thread Alexander Ilin
You open a file, read one line, then reopen the file and do the same again.Since you are reopening the stream, there's always data available, thus there is no reason to yield. 14.09.2019, 21:04, "murray.calavera--- via Factor-talk" :Hello all, I'm a bit confused about how threads work with IO in factor.  This: https://docs.factorcode.org/content/article-threads.html seems to imply that functions such as readln will yield  to other threads unless data is available on a stream, but the following program only ever reads from the fifo: USING: kernel threads io io.files io.encodings.utf8 ;
IN: test

: read-fifo ( -- )
    "fifo" utf8 [ readln print flush ] with-file-reader read-fifo ;

: read-stdin ( -- )
    readln print flush read-stdin ;

[ read-fifo ] "fifo-thread" spawn drop
read-stdin

 What am I misunderstanding here?
Thanks.
Murray.
 ,,___Factor-talk mailing listFactor-talk@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/factor-talk  ---=---Александр 

___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Co-operative threading

2019-09-14 Thread murray.calavera--- via Factor-talk
Hello all,

I'm a bit confused about how threads work with IO in factor.

This: https://docs.factorcode.org/content/article-threads.html seems to imply 
that functions such as readln will yield  to other threads unless data is 
available on a stream, but the following program only ever reads from the fifo:

USING:

kernel threads io io.files io.encodings.utf8

;

IN: test

: read-fifo

( --

)

"fifo"

utf8

[

readln print flush

]

with-file-reader read-fifo

;

: read-stdin

( --

)

readln print flush read-stdin

;

[

read-fifo

]

"fifo-thread"

spawn drop
read-stdin

What am I misunderstanding here?

Thanks.

Murray.___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk