It seems to localize single variables but not arrays. I could even
implement an async that I could interrupt by updating values in a global
array. I actually don't know of any sane way to do this, i.e., interrupt a
task or an async bloc from the main thread?
global x = zeros(1)
@async begin
for i = 1:6
if x[1] > 0
break
end
println("hi $x")
sleep(5)
end
end
then it starts outputting
hi [0.0]
Task (queued) @0x00000001089daf80
hi [0.0]
then once I input
> x[1] = 1
it stops. the async block can also as it runs update the entries of a
global array, so that the global array has different values that you can
access from the interpreter at different times as the async block is
running; this is one way I found to do something like a background task,
and unfortunately I don't know of any sane way to do that in Julia either.
Is there?
On Friday, March 28, 2014 9:50:29 AM UTC-7, Collin Glass wrote:
>
> Interesting thread. What should one use to have a chunk of asynchronous
> code that does not localize variables?
>
>
> On Saturday, July 20, 2013 4:23:21 AM UTC-4, Amit Murthy wrote:
>>
>> My understanding is that "let" blocks only localize variables explicitly
>> specified on the first line, while @async localizes all variables.
>>
>>
>> On Sat, Jul 20, 2013 at 1:01 PM, Toivo Henningsson <[email protected]>
>> wrote:
>>
>>> Alternatively, @async could require to be invoked as @async let ... end
>>>
>>
>>