Has there been any discussion on a mechanism (either in the language or by convention) for marking calls that might block? I couldn't find any issues and the only list discussion was this one[1], which describes running into the problem. A simple "list of calls that might yield" isn't super useful because any function you call that calls one of the functions that might yield, might yield. (The transitive property of yielding?)
I'm guessing that most motivations for preventing yielding boil down to situations where tasks (or any function called from within tasks) share state by accessing or modifying global variables. For example in the OP's code, if multiple tasks are executing that code and `some_index` is global, some yielding operation in the loop will likely mess up the process. On Tue, Feb 3, 2015, at 10:57 AM, Stefan Karpinski wrote: > Anything that might block might yield – so I/O and sleep. If you don't > do anything that might block, then your code won't yield. What's the > motivation for wanting to prevent yielding? > > On Tue, Feb 3, 2015 at 10:54 AM, Ben Arthur > <[email protected]> wrote: >> is there a way to mark a section of code within a task to run as an >> atomic unit? in other words, to prevent the scheduler from switching >> to a different task within this section? >> >> for example, i'd like have more than one @sync task running this same >> snippet of code on the same global variables: >> >> ``` some_array[some_index]=some_data some_index+=1 ``` >> >> alternatively, is there a list of commands which are prone to yield >> that one could then avoid in a sensitive section of code? i don't see >> one in the docs... >> >> thanks, >> >> ben > Links: 1. https://groups.google.com/d/topic/julia-users/l-Fyl4fWv2Y/discussion
