Message from JavaScript discussions

January 2019

— Depends on how you use it


If a dispatcher loses control and a hzfunctor gets called by a non-hzfunctor, like when you give a callback to a non-compiled function, then a new dispatcher is started at the call site

— At that call site there is no preemption possible, it just tries to emulate if the code was not threaded at all and normal js code

Message permanent page

— As a fail safe

— I don't imagine it

— I mean, I have a model right now in my mind

— I'm trying to think how to adapt it to Hz

— My idea is the following

— We compile two functions, or co-rutines

— For example the statues example, there is one dispatcher interleaving the execution of two functions, right? and this dispatcher code gets embedded into the script after compiling it, right? so in my opinion we can use a dispatcher per thread, so each real thread runs multiple functions at same time, but you also run multiple dispatchers with other functions. With this approach it would be easier to implement..

Message permanent page

— Now the thing is, do you want communication between threads through callback? or do you want to use channels?

in any of both cases dispatcher must have a way to hook into it from outside, in order to give the control to the host (metacall) and deal with control mechanisms like channels or execute the protected callbacks with a copy like fp

Message permanent page

— What about shared state?