asynchronous - Julia: understanding when task switching happens -
I could not find detailed documentation about the macro. From documents about equality, I think that Julia is the only system thread used in the process and the clear work switching is done with the help of the yield
function - if I am wrong about this Correct me
It is difficult for me to understand that when this work is done only by looking at the code, it is important to know when this happens.
As I did in a above
code (or some functions called by the code) somewhere to make sure that the system is not only with one function.
For example, when a read
is inside the operation, maybe there is a wait
call and the implementation of wait
There is probably a yield
in the name of Pu. I thought without the yield
the call code would get stuck in one task; Although the following example is running, this estimate is proved wrong.
Start @async # Task A while the correct println ("A") is the end of the end while the correct # Task B println ("B") end
< P> This code produces the following output ba ba ...
This is very unclear to me where the code switching code above @async
is inside the work created by the macro.
How can I tell about some code where the switching function is like this?
println ("A") inside the task switch call
, Which at ISA (STDOUT, Base.AsyncStream)
and there is no special method that fixes this to:
write {T} (s :: AsyncStream) , A :: array {T}) at stream.jl: 782
If you look at this method, you will see that it is stream_wait (ct)
Calls the current work ct
, which in turn wait ()
. <(Also keep in mind that println
is not atom, because there is a potential between
between logic and new line writing.)
By the way, you can decide when the stuff all is included but I do not know why you need to know it exactly because, while working with parallelism, Do not want to depend on the not switching process E. If you rely on a certain execution order, then clearly synchronize.
(You have already made this note in your question, but repeat it here: As a rule of thumb, while using Green Threads, you expect the possible reference switch when doing the IO Because the barrier for IO is a textbook example, why green threads are useful in the first place.)
Comments
Post a Comment