We have moved at community.getvera.com

Author Topic: Parallel run of plugin's code  (Read 1287 times)

Offline lolodomo

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Parallel run of plugin's code
« on: November 15, 2012, 03:50:51 pm »
What happens when you have a plugin attached to several devices and you run the same callback in parallel for several of these devices ? Is the plugin's code totally independent for each device ? What's about lul_settings, local variables of the plugin ?
Can it be a source of problems ?

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Parallel run of plugin's code
« Reply #1 on: November 15, 2012, 04:25:10 pm »
A Plugin provides the implementation of a device.

Each device has it's own Sandbox to operate in. So they will not interfere with each other.

i.e. the code for the plugin is shared, but the variables are unique to each device instance.

To share data between devices you must get/set Service variables on another device.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Parallel run of plugin's code
« Reply #2 on: November 15, 2012, 05:12:18 pm »
I believe each device gets a separate [internal] Lua_state struct to keep it isolated, and everything uses locks to avoid execution concurrency within that Lua_state (eg. Two timers don't actually run concurrently)