You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But it is not clear if that's something that can guarantee the desired behavior. The doubt is based on these questions:
Are tasks spawned guaranteed to start executing in the order in which they were spawned?
And are locks guaranteed to be granted in the same order in which they were requested?
In this example below, that is what happens:
julia>using Base.Threads
julia>functiontest1()
lck = Threads.Condition()
val =10@syncbeginfor idx in1:50@asyncbeginlock(lck) do
val = idx
endendendendprintln("val: $val")
end
test1 (generic function with 1 method)
julia>test1()
val:50
julia>test1()
val:50
But making the task yield randomly makes the result different every time:
julia>functiontest2()
lck = Threads.Condition()
val =10@syncbeginfor idx in1:50@asyncbeginsleep(rand())
lock(lck) do
val = idx
endendendendprintln("val: $val")
end
test2 (generic function with 1 method)
julia>test2()
val:45
julia>test2()
val:8
The question is in absence of any random yield (as in test2), is the execution order (as in test1) something that is guaranteed in Julia?
The text was updated successfully, but these errors were encountered:
The docstring for
async_execute
mentions: https://github.com/iamed2/LibPQ.jl/blob/2c0547daef005e160aa60cb529d4969a670befbc/src/asyncresults.jl#L203-L204The actual implementation does this for synchronization in the method: https://github.com/iamed2/LibPQ.jl/blob/2c0547daef005e160aa60cb529d4969a670befbc/src/asyncresults.jl#L270
But it is not clear if that's something that can guarantee the desired behavior. The doubt is based on these questions:
In this example below, that is what happens:
But making the task yield randomly makes the result different every time:
The question is in absence of any random yield (as in test2), is the execution order (as in test1) something that is guaranteed in Julia?
The text was updated successfully, but these errors were encountered: