Available since LÖVE 0.10.0
This function is not supported in earlier versions.
Executes the specified function atomically with respect to this Channel.
Calling multiple methods in a row on the same Channel is often useful. However if multiple Threads are calling this Channel's methods at the same time, the different calls on each Thread might end up interleaved (e.g. one or more of the second thread's calls may happen in between the first thread's calls.)
This method avoids that issue by making sure the Thread calling the method has exclusive access to the Channel until the specified function has returned.
Long-running or otherwise expensive code should be avoided in the function given to this method.
ret1, ... = Channel:performAtomic( func, arg1, ... )
function func
function(channel, arg1, arg2, ...) end
. The Channel is passed as the first argument to the function when it is called.any arg1
any ...
local function setChannel(channel, value) channel:clear() channel:push(value) end local c = love.thread.getChannel("MyChannel") c:performAtomic(setChannel, "hello world")
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/Channel:performAtomic