Regular API function

sim.setThreadSwitchAllowed

Description Allows to temporarily forbid all thread interruptions, including explicit interruptions or switches. For complete control over thread switching, see also sim.getThreadSwitchAllowed, sim.setThreadAutomaticSwitch, sim.setThreadSwitchTiming and sim.switchThread.
C synopsis
C parameters
C return value
Lua synopsis int switchForbidLevel=sim.setThreadSwitchAllowed(boolean allowSwitch / int forbidLevel)
Lua parameters
allowSwitch: if false, then the thread will not be interrupted anymore (i.e. thread switching will be temporarily disabled). Calling n times sim.setThreadSwitchAllowed(false) requires to call n times sim.setThreadSwitchAllowed(true) to restore the initial behaviour.
forbidLevel: allows to set a switch forbid level: a level > 0 indicates that thread interruption is disabled.
Best is to always use following to temporarily forbid thread interruptions:
local initialForbidLevel=sim.setThreadSwitchAllowed(false) -- forbid thread switches
...
sim.setThreadSwitchAllowed(initialForbidLevel) -- restore to initial state
Lua return values
switchForbidLevel: the forbid switch level before calling the function, i.e. the forbid switch level that should be restored later on.