Regular API function

sim.setThreadAutomaticSwitch

Description Allows to temporarily forbid automatic thread interruptions, i.e. preemptive threading. Explicit thread interruptions, i.e. switching, are still allowed. For complete control over thread switching, see also the other thread related functions.
C/C++
synopsis
C/C++
parameters
C/C++
return value
Lua
synopsis
int autoSwitchForbidLevel=sim.setThreadAutomaticSwitch(bool allowAutoSwitch / int forbidLevel)
Lua
parameters
allowAutoSwitch: if false, then the thread will not be automatically interrupted anymore (i.e. automatic thread switching will be temporarily disabled). Calling n times sim.setThreadAutomaticSwitch(false) requires to call n times sim.setThreadAutomaticSwitch(true) to restore the initial behaviour.
forbidLevel: allows to set an auto switch forbid level: a level > 0 indicates that automatic thread interruption is disabled.
Best is to always use following to temporarily forbid automatic thread interruptions:
local initialForbidLevel=sim.setThreadAutomaticSwitch(false) -- forbid automatic thread switches ... sim.setThreadAutomaticSwitch(initialForbidLevel) -- restore to initial state
Lua
return values
autoSwitchForbidLevel: the forbid switch level before calling the function, i.e. the forbid switch level that should be restored later on.
Python
synopsis
int autoSwitchForbidLevel=sim.setThreadAutomaticSwitch(bool allowAutoSwitch / int forbidLevel)

<