Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jrubyscripting] Add ConfigurableService #9

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

jimtng
Copy link

@jimtng jimtng commented Nov 13, 2021

I added ConfigurableService as suggested by wborn. I've also set the default to singlethread since that's the config that works for scriptUnloaded see boc-tothefuture/openhab-jruby#397

Signed-off-by: Jimmy Tanagra <jimmy@tanagra.id.au>
@boc-tothefuture
Copy link
Owner

Ok. I added the configurable service as well but haven't pushed it yet. I will merge our two changes together where it makes sense.

Have you tried single threaded? I think it will cause a lot of issues:. boc-tothefuture/openhab-jruby#46 has the discussion of the impact of each of these.

@jimtng
Copy link
Author

jimtng commented Nov 13, 2021

I am running singlethread on my production environment as of today. So far everything seems to be running as normal.

@jimtng
Copy link
Author

jimtng commented Nov 13, 2021

I don't fully understand the issue surrounding multi-threads with the jruby. Could you give an example scenario where singlethread would cause a problem?

If I understand it correctly:

  • Each rule file gets its own scriptengine instance
  • rules in different files should have no problems because they are running in a completely different script engine, like a separate 'virtual machine'
  • multiple rules in the same file will share the same scriptengine, and can access the same instance variables and top-level variables. However they could be running concurrently through different threads, so modifications to variables that are visible to multiple rules (within the same file) are subject to multi-threading issues and therefore may need to be synchronised
  • threadsafe option automatically manage the access to such variables, therefore no explicit synchronisations are required
  • singlethread doesn't have such management

I could probably gain a better understanding if I spent some time digging into jruby's code but that would take time and some serious brain exercise.

@boc-tothefuture
Copy link
Owner

Merging this, moving discussion to thread context over to:
boc-tothefuture/openhab-jruby#46

@boc-tothefuture boc-tothefuture merged commit 5de8cf1 into boc-tothefuture:jruby Nov 13, 2021
@jimtng jimtng deleted the jruby-configurations branch February 4, 2022 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants